本文整理汇总了PHP中Illuminate\Contracts\Auth\Authenticatable::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Authenticatable::save方法的具体用法?PHP Authenticatable::save怎么用?PHP Authenticatable::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Auth\Authenticatable
的用法示例。
在下文中一共展示了Authenticatable::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateRememberToken
/**
* 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();
}
}
示例2: validateCredentials
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;
}
示例3: verify
/**
* 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)]);
}
}
示例4: saveProfile
/**
* Изменение данных в профиле пользователя
* @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');
}
示例5: validateCredentials
/**
* {@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;
}
示例6: validateCredentials
/**
* 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());
}
示例7: updateUserInfo
/**
* 寫入登入時間及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'));
}
示例8: syncModelFromAdldap
/**
* 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;
}
示例9: changePassword
/**
* 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());
}
}
示例10: updateRememberToken
/**
* 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]);
}
}
}
示例11: onLogin
/**
* 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();
}
示例12: syncModelFromAdldap
/**
* 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;
}
示例13: syncModelFromAdldap
/**
* 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;
}
示例14: updateRememberToken
/**
* 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();
}
示例15: updateUser
/**
* 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();
}