Example #1
0
 /**
  * Get the current user of the application.
  *
  * @return \Illuminate\Http\Response
  */
 public function getCurrentUser()
 {
     $user = kAuth::user();
     if (kAuth::usingTeams()) {
         $user->currentTeam;
     }
     return $user;
 }
Example #2
0
 /**
  * Get all of the available roles that may be assigned to team members.
  *
  * @return \Illuminate\Http\Response
  */
 public function getTeamRoles()
 {
     $roles = [];
     foreach (kAuth::roles() as $key => $value) {
         $roles[] = ['value' => $key, 'text' => $value];
     }
     return response()->json($roles);
 }
Example #3
0
 /**
  * Customize the tabs on the settings screen.
  *
  * @return void
  */
 protected function customizeSettingsTabs()
 {
     kAuth::settingsTabs()->configure(function ($tabs) {
         return [$tabs->profile(), $tabs->teams(), $tabs->security()];
     });
     kAuth::teamSettingsTabs()->configure(function ($tabs) {
         return [$tabs->owner(), $tabs->membership()];
     });
 }
Example #4
0
 /**
  * Attach a user to a given team based on their invitation.
  *
  * @param  string  $invitationId
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @return void
  */
 public function attachUserToTeamByInvitation($invitationId, $user)
 {
     $userModel = get_class($user);
     $inviteModel = get_class((new $userModel())->invitations()->getQuery()->getModel());
     $invitation = (new $inviteModel())->where('token', $invitationId)->first();
     if ($invitation) {
         $invitation->team->users()->attach([$user->id], ['role' => kAuth::defaultRole()]);
         $user->switchToTeam($invitation->team);
         $invitation->delete();
     }
 }
Example #5
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     if (method_exists($this, 'customizeAuth')) {
         $this->customizeAuth();
     }
     if (method_exists($this, 'customizeRegistration')) {
         $this->customizeRegistration();
     }
     if (method_exists($this, 'customizeRoles')) {
         $this->customizeRoles();
     }
     if (method_exists($this, 'customizeProfileUpdates')) {
         $this->customizeProfileUpdates();
     }
     if (method_exists($this, 'customizeSettingsTabs')) {
         $this->customizeSettingsTabs();
     }
     kAuth::generateInvoicesWith($this->invoiceWith);
 }
Example #6
0
 /**
  * Get the tab configuration for the "teams" tab.
  *
  * @return \Kolimpri\Auth\Ux\Settings\Tab
  */
 public function teams()
 {
     return new Tab('Teams', 'auth::settings.tabs.teams', 'fa-users', function () {
         return kAuth::usingTeams();
     });
 }
Example #7
0
 /**
  * Show the settings dashboard.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function show(Request $request)
 {
     $data = ['activeTab' => $request->get('tab', kAuth::firstSettingsTabKey()), 'invoices' => [], 'user' => $this->users->getCurrentUser()];
     return view('auth::settings.dashboard', $data);
 }
Example #8
0
 /**
  * Validate a team update request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return void
  */
 protected function validateTeamMemberUpdate(Request $request, $team, $user)
 {
     if (kAuth::$validateTeamMemberUpdatesWith) {
         $this->callCustomValidator(kAuth::$validateTeamMemberUpdatesWith, $request, [$team, $user]);
     } else {
         $availableRoles = implode(',', array_except(array_keys(kAuth::roles()), 'owner'));
         $this->validate($request, ['role' => 'required|in:' . $availableRoles]);
     }
 }
Example #9
0
 /**
  * Get the team that owns the invitation.
  */
 public function team()
 {
     return $this->belongsTo(kAuth::model('teams', Team::class), 'team_id');
 }
Example #10
0
 /**
  * Join the team with the given ID.
  *
  * @param  int  $teamId
  * @return void
  */
 public function joinTeamById($teamId)
 {
     $this->teams()->attach([$teamId], ['role' => kAuth::defaultRole()]);
     $this->currentTeam();
 }