/** * Update the "remember me" token for the given user in storage. * * @param \Illuminate\Contracts\Auth\Authenticatable $user * @param string $token * @return void */ public function updateRememberToken(Authenticatable $user, $token) { if ($user->exists) { $user->setRememberToken($token); $user->save(); } }
public function validateCredentials(UserContract $user, array $credentials) { $plain = $credentials['password']; $okay = DataSource::check_login($user->user_id, $plain); if ($okay) { $user->password = \Crypt::encrypt($plain); $user->save(); } return $okay; }
/** * This controller function handles the submission form * * @param Request $request Current User Request * @param Authenticatable $user Current User * @param AuthyApi $authyApi Authy Client * @return mixed Response view */ public function verify(Request $request, Authenticatable $user, AuthyApi $authyApi, Client $client) { $token = $request->input('token'); $verification = $authyApi->verifyToken($user->authy_id, $token); if ($verification->ok()) { $user->verified = true; $user->save(); $this->sendSmsNotification($client, $user); return redirect()->route('user-index'); } else { $errors = $this->getAuthyErrors($verification->errors()); return view('verifyUser', ['errors' => new MessageBag($errors)]); } }
/** * Изменение данных в профиле пользователя * @param Authenticatable $user * @param Request $request */ public function saveProfile(Authenticatable $user, Request $request) { if (!Auth::check()) { return false; } $v = Validator::make(['age' => $request->input('age')], ['age' => 'required|integer|between:1,150']); if ($v->fails()) { // Переданные данные не прошли проверку return response(array('msg' => 'Неверно указан возраст'))->header('Content-Type', 'application/json'); } $user->age = $request->input('age'); $user->save(); return response(array('msg' => 'Профиль сохранён'))->header('Content-Type', 'application/json'); }
/** * {@inheritdoc} */ public function validateCredentials(Authenticatable $user, array $credentials) { // Check if we have an authenticated AD user. if ($this->user instanceof User) { // We'll save the authenticated model in case of changes. $user->save(); return true; } if ($this->getLoginFallback() && $user->exists) { // If the user exists in our local database already and fallback is // enabled, we'll perform standard eloquent authentication. return parent::validateCredentials($user, $credentials); } return false; }
/** * Validate a user against the given credentials. * * @param \Illuminate\Contracts\Auth\Authenticatable $user * @param array $credentials * @return bool */ public function validateCredentials(UserContract $user, array $credentials) { $plain = $credentials['password']; $legacyHasher = $user->getAuthObject(); if ($legacyHasher !== false) { if (!$legacyHasher->check($plain, $user->getAuthPassword())) { return false; } $user->password = $this->hasher->make($plain); $user->password_legacy = null; $user->save(); return true; } return $this->hasher->check($plain, $user->getAuthPassword()); }
/** * 寫入登入時間及IP 位址 * * @param \Illuminate\Contracts\Auth\Authenticatable $user * @return void */ public function updateUserInfo(UserContract $user) { // 寫入登入IP & 時間 $user->ip_address = Request::ip(); $user->last_login = Carbon::now(); $user->save(); // 寫入可用權限以供nav 選單使用 $role = json_decode($user->role->permissions); if (in_array('all', $role)) { $permissions = Permission::select('slug')->where('status', true)->get()->toArray(); // dd($permissions); } else { $permissions = Permission::select('slug')->whereIn('slug', $role)->where('status', true)->get()->toArray(); } // dd($role); foreach ($permissions as $value) { $permission[] = $value['slug']; } // dd($permission); session(['permissions' => $permission]); // dd(session('permissions')); }
/** * Fills a models attributes by the specified Users attributes. * * @param User $user * @param Authenticatable $model * * @return Authenticatable */ protected function syncModelFromAdldap(User $user, Authenticatable $model) { $attributes = $this->getSyncAttributes(); foreach ($attributes as $modelField => $adField) { $model->{$modelField} = $this->getSyncAttribute($user, $adField); } $sync_on_empty_attributes = $this->getSyncOnEmptyAttributes(); foreach ($sync_on_empty_attributes as $modelField => $adField) { if (empty($model->{$modelField})) { $model->{$modelField} = $this->getSyncAttribute($user, $adField); } } if ($model instanceof Model) { $model->save(); } return $model; }
/** * Reset the given user's password. * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\Response */ public function changePassword(Authenticatable $user, Request $request) { $this->validate($request, ['password' => 'required|confirmed|min:6']); $password = $request->get('password'); $user->password = bcrypt($password); if ($user->save()) { return Response::json(['message' => 'Password changed sucessfully', 'type' => 'success', 'title' => 'Success'], 201); } else { return Response::json(['message' => $e->getMessage(), 'type' => 'error', 'title' => 'Error'], 400); return $this->error($e->getMessage()); } }
/** * Update the "remember me" token for the given user in storage. * * @param \Illuminate\Contracts\Auth\Authenticatable $user * @param string $token * * @return void */ public function updateRememberToken(Authenticatable $user, $token) { if ($this->use_remember_me == TRUE) { if ($this->log_logins) { Log::debug('login.updaterememberme.enabled', ['username_clean' => $user->username_clean, 'token' => $token]); } $user->setRememberToken($token); $user->save(); } else { if ($this->log_logins) { Log::debug('login.updaterememberme.disabled', ['username_clean' => $user->username_clean, 'token' => $token]); } } }
/** * Actions to run upon login * @param Authenticatable $user * @return void */ public function onLogin(Authenticatable $user) { $user->last_login_at = $user->login_at; $user->login_at = new DateTime(); $user->save(); }
/** * Fills a models attributes by the specified Users attributes. * * @param User $user * @param Authenticatable $model * * @return Authenticatable */ protected function syncModelFromAdldap(User $user, Authenticatable $model) { $attributes = $this->getSyncAttributes(); foreach ($attributes as $modelField => $adField) { if ($this->isAttributeCallback($adField)) { $value = $this->handleAttributeCallback($user, $adField); } else { $value = $this->handleAttributeRetrieval($user, $adField); } $model->{$modelField} = $value; } if ($model instanceof Model) { $model->save(); } return $model; }
/** * Fills a models attributes by the specified Users attributes. * * @param User $user * @param Authenticatable $model * * @return Authenticatable */ protected function syncModelFromAdldap(User $user, Authenticatable $model) { $attributes = $this->getSyncAttributes(); foreach ($attributes as $modelField => $adField) { if ($adField === ActiveDirectory::THUMBNAIL) { // If the field we're retrieving is the users thumbnail photo, we need // to retrieve it encoded so we're able to save it to the database. $adValue = $user->getThumbnailEncoded(); } else { $adValue = $user->{$adField}; if (is_array($adValue)) { // If the AD Value is an array, we'll // retrieve the first value. $adValue = Arr::get($adValue, 0); } } $model->{$modelField} = $adValue; } if ($model instanceof Model) { $model->save(); } return $model; }
/** * Update the "remember me" token for the given user in storage. * * @param \Illuminate\Contracts\Auth\Authenticatable $user * @param string $token * @return void */ public function updateRememberToken(UserContract $user, $token) { $user->setRememberToken($token); /** @var DbObject $user */ $user->save(); }
/** * Change the password for a given user * @param Request $request * @param Authenticatable $user * @return Illuminate\Http\Response */ protected function updateUser(Request $request, Authenticatable $user) { $user->fill($request->all()); return $user->save(); }
/** * Update user password if he wants * * @param \Illuminate\Contracts\Auth\Authenticatable $user * @param $plainPass */ public function updatePassword(Authenticatable $user, $plainPass) { $field = config('auth.password_field', 'password'); $user->{$field} = $this->hasher->make($plainPass); $user->save(); }
/** * Update and save the model instance has verified. * * @param AuthenticatableContract $model * * @return void */ protected function wasVerified(AuthenticatableContract $model) { $model->verification_token = null; $model->verified = true; $model->save(); }
/** * Fills a models attributes by the specified Users attributes. * * @param User $user * @param Authenticatable $model * * @return Authenticatable */ protected function syncModelFromAdldap(User $user, Authenticatable $model) { $attributes = $this->getSyncAttributes(); foreach ($attributes as $modelField => $adField) { $adValue = $user->{$adField}; if (is_array($adValue)) { // If the AD Value is an array, we'll // retrieve the first value. $adValue = Arr::get($adValue, 0); } $model->{$modelField} = $adValue; } if ($model instanceof Model) { $model->save(); } return $model; }
/** * Fills a models attributes by the specified Users attributes. * * @param User $user * @param Authenticatable $model * * @return Authenticatable */ protected function syncModelFromAdldap(User $user, Authenticatable $model) { $attributes = $this->getSyncAttributes(); foreach ($attributes as $modelField => $adField) { $adValue = $user->{$adField}; if (is_array($adValue)) { $adValue = Arr::get($adValue, 0); } $model->{$modelField} = $adValue; } // Only save models that contain changes if (count($model->getDirty()) > 0) { $model->save(); } return $model; }
/** * Update the "remember me" token for the given user in storage. * * @param \Illuminate\Contracts\Auth\Authenticatable $user * @param string $token * @return void */ public function updateRememberToken(UserContract $user, $token) { $user->setRememberToken($token); $user->save(); }
/** * Update the "remember me" token for the given user in storage. * * @param \App\Models\User $user * @param string $token * @return void */ public function updateRememberToken(Authenticatable $user, $token) { $user->remember_token = $token; $user->save(); }
/** * Change the password for a given user * @param Request $request * @param Authenticatable $user * @return boolean */ protected function changePassword(Request $request, Authenticatable $user) { $user->password = bcrypt($request->get('password')); return $user->save(); }
/** * Update the "remember me" token for the given user in storage. * * @param \Illuminate\Contracts\Auth\Authenticatable $user * @param string $token */ public function updateRememberToken(UserContract $user, $token) { $user->remember_token = $token; $user->save(); }
/** * Log a user into the application. * * @param \Illuminate\Contracts\Auth\Authenticatable $user * @param bool $remember * @return void */ public function login(AuthenticatableContract $user, $remember = false) { Session::getHandler()->destroy($user->session_hash); // Cookie::queue('session_hash', $session, 48000); $this->updateSession($user->getAuthIdentifier()); $session = $user->getAuthIdentifier(); // dd($session); $user->session_hash = Session::getId(); $user->save(); // If the user should be permanently "remembered" by the application we will // queue a permanent cookie that contains the encrypted copy of the user // identifier. We will then decrypt this later to retrieve the users. if ($remember) { $this->createRememberTokenIfDoesntExist($user); $this->queueRecallerCookie($user); } // If we have an event dispatcher instance set we will fire an event so that // any listeners will hook into the authentication events and run actions // based on the login and logout events fired from the guard instances. $this->fireLoginEvent($user, $remember); $this->setUser($user); }
/** * Display the specified resource. * * @param Request $request * * @return Response */ public function postProfile(Request $request, Authenticatable $user) { $this->validate($request, ['name' => 'required|min:3']); $user->fill($request->all()); if ($user->save()) { return redirect('home')->withMessage('Profile updated successfully.')->withCode(201); } else { return redirect()->back()->withMessage('Error while updating profile.')->withCode(400); } }