Esempio n. 1
0
 public function send_contract_new_mod($forum_user_id, $contract_id)
 {
     $contract = SyndieContract::find($contract_id);
     $forum_user = ForumUserModel::find($forum_user_id);
     $from_name = config('aurora.syndie_contract_from_name');
     $from_address = config('aurora.syndie_contract_from_address');
     //Get user E-Mail
     Mail::send('emails.contract_new_mod', ['forum_user' => $forum_user, 'contract' => $contract], function ($m) use($forum_user, $contract, $from_name, $from_address) {
         $m->from($from_address, $from_name);
         $m->to($forum_user->user_email, $forum_user->username);
         $m->subject('Contract Update - ' . $contract->title);
     });
 }
Esempio n. 2
0
 public function get_users($user_models = FALSE)
 {
     $users = DB::connection($this->connection)->table('role_user')->where('role_id', $this->id)->pluck('user_id');
     if (!$user_models) {
         return $users;
     } else {
         $user_data = array();
         foreach ($users as $user) {
             $user_data[] = ForumUserModel::findOrFail($user);
         }
         return Collection::make($user_data);
     }
 }
 /**
  * Logs the user in by supplying a username and a login token
  */
 public function sso_server(Request $request)
 {
     $ckey_in = NULL;
     $token_in = NULL;
     $location = NULL;
     //Get the token and the ckey from the request
     $ckey_in = $request->input('ckey');
     $token_in = $request->input('token');
     $location = $request->input('location');
     $user_ip = $_SERVER['REMOTE_ADDR'];
     if ($ckey_in == NULL | $token_in == NULL) {
         abort(404);
     }
     //Check if a sso entry for the ckey and token exists
     $valid_until = Carbon::now();
     $valid_until->subHours(config('aurora.token_valid_time'));
     $count = DB::connection('server')->table('web_sso')->where('ckey', $ckey_in)->where('token', $token_in)->where('ip', $user_ip)->where('created_at', '>', $valid_until->toDateTimeString())->count();
     if ($count == 0) {
         abort(404);
     }
     //Check if a user with a linked byond account exists in the forum db
     $user = ForumUserModel::where('user_byond', $ckey_in)->first();
     if ($user == NULL) {
         return view('errors.no_user_linked', array('ckey' => $ckey_in));
     }
     //Auth the user
     Auth::login($user);
     //Delete the sso entry from the db
     DB::connection('server')->table('web_sso')->where('ckey', $ckey_in)->delete();
     //Redirect User to Destination
     switch ($location) {
         case "user_dashboard":
             return redirect()->route('user.dashboard');
             break;
         case "contract_overview":
             return redirect()->route('syndie.contracts.index');
             break;
         case "contract_details":
             return redirect()->route('syndie.contracts.show', ['contract' => $request->input('contract')]);
             break;
         case "security_incident":
             return redirect()->route('server.incidents.show.get', ['contract' => $request->input('incident')]);
             break;
         default:
             return redirect()->route('user.dashboard');
             break;
     }
 }
 /**
  * Retrieve a user by by their unique identifier and "remember me" token.
  *
  * @param  mixed  $identifier
  * @param  string $token
  *
  * @return \Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function retrieveByToken($identifier, $token)
 {
     if ($this->use_remember_me == TRUE) {
         $qry = ForumUserModel::where('username_clean', '=', strtolower($identifier))->where('wi_remember_token', '=', $token);
         if ($qry->count() > 0) {
             $user = $qry->select('user_id', 'username', 'username_clean', 'user_password', 'user_email', 'user_byond', 'user_byond_linked')->first();
             if ($this->log_logins) {
                 Log::debug('login.retrievebytoken.success', ['username_clean' => strtolower($identifier)]);
             }
             return $user;
         }
         if ($this->log_logins) {
             Log::debug('login.retrievebytoken.fail', ['username_clean' => strtolower($identifier)]);
         }
     }
     if ($this->log_logins) {
         Log::debug('login.retrievebytoken.disabled', ['username_clean' => strtolower($identifier)]);
     }
     return NULL;
 }
 public function removeUser(Request $request, $role_id)
 {
     if ($request->user()->cannot('site_roles_edit')) {
         abort('403', 'You do not have the required permission');
     }
     $role = SiteRole::findOrFail($role_id);
     $user = ForumUserModel::findOrFail($request->input('user'));
     $user->roles()->detach($role);
     Log::notice('perm.site_role.remove_user - Site Role User removed', ['user_id' => $request->user()->user_id, 'role_id' => $role->id, 'role_name' => $role->name, 'target_user_id' => $user->user_id, 'target_user_name' => $user->username_clean]);
     return redirect()->route('site.roles.edit.get', ['role_id' => $role_id]);
 }
 public function retrieveByCredentials(array $credentials)
 {
     $qry = ForumUser::where('username_clean', '=', strtolower($credentials['username']));
     if ($qry->count() > 0) {
         $user = $qry->select('user_id', 'username', 'username_clean', 'user_password', 'user_email', 'user_new_privmsg', 'user_unread_privmsg', 'user_byond', 'user_byond_linked')->first();
         if ($this->log_logins) {
             Log::debug('login.retrievebycredentials.success', ['username_clean' => strtolower($credentials['username'])]);
         }
         return $user;
     }
     if ($this->log_logins) {
         Log::debug('login.retrievebycredentials.fail', ['username_clean' => strtolower($credentials['username'])]);
     }
     return NULL;
 }
 /**
  * Logs the user in by supplying a username and a login token
  */
 public function sso_server(Request $request)
 {
     $ckey_in = NULL;
     $token_in = NULL;
     $location = NULL;
     //Get the token and the ckey from the request
     $ckey_in = $request->input('ckey');
     $token_in = $request->input('token');
     $location = $request->input('location');
     $user_ip = $_SERVER['REMOTE_ADDR'];
     if (Auth::check()) {
         $this->redirect_after_sso($location, $request);
     }
     if ($ckey_in == NULL | $token_in == NULL) {
         abort(404);
     }
     //Check if a sso entry for the ckey and token exists
     $valid_until = Carbon::now();
     $valid_until->subHours(config('aurora.token_valid_time'));
     $count = DB::connection('server')->table('web_sso')->where('ckey', $ckey_in)->where('token', $token_in)->where('ip', $user_ip)->where('created_at', '>', $valid_until->toDateTimeString())->count();
     if ($count == 0) {
         abort(404);
     }
     //Check if a user with a linked byond account exists in the forum db
     $user = ForumUserModel::where('user_byond', $ckey_in)->first();
     if ($user == NULL) {
         return view('errors.no_user_linked', array('ckey' => $ckey_in));
     }
     //Auth the user
     Auth::login($user);
     //Delete the sso entry from the db
     DB::connection('server')->table('web_sso')->where('ckey', $ckey_in)->delete();
     $this->redirect_after_sso($location, $request);
 }