本文整理汇总了PHP中Illuminate\Contracts\Auth\Authenticatable类的典型用法代码示例。如果您正苦于以下问题:PHP Authenticatable类的具体用法?PHP Authenticatable怎么用?PHP Authenticatable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Authenticatable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: subscribed
/**
* Determine if the given user is subscribed to the given plan.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $subscription
* @param string $plan
* @param bool $defaultSubscription
* @return bool
*/
protected function subscribed($user, $subscription, $plan, $defaultSubscription)
{
if (!$user) {
return false;
}
return $defaultSubscription && $user->onGenericTrial() || $user->subscribed($subscription, $plan);
}
示例2: validateCredentials
/**
* Validate a user against the given credentials.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials
* @return bool
*/
public function validateCredentials(Authenticatable $user, array $credentials)
{
if (!isset($credentials['password'])) {
return false;
}
return $user->getAuthPassword() === $credentials['password'];
}
示例3: 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();
}
}
示例4: validateCredentials
/**
* Validate a user against the given credentials.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials
* @return bool
*/
public function validateCredentials(Authenticatable $user, array $credentials)
{
// $is_valid = $this->model->where('Username', '=', $credentials['Username'])->where('Password', '=', $credentials['Password'])->first() != null;
$is_valid = $user->Username == $credentials['Username'] && $this->hasher->check($credentials['Password'], $user->getAuthPassword());
return $is_valid;
// $plain = $credentials['password'];
// return $this->hasher->check($plain, $user->getAuthPassword());
}
示例5: validateCredentials
/**
* @param Authenticatable $user
* @param array $credentials
* @return bool
*/
public function validateCredentials(Authenticatable $user, array $credentials)
{
if ($user->type == 'local') {
$plain = $credentials['password'];
return $this->hasher->check($plain, $user->getAuthPassword());
}
return true;
}
示例6: createActivity
/**
* Create user login activity
*
* @param Authenticatable $user
* @param $event_name
* @return bool
*/
protected function createActivity($user, $event_name)
{
if (!$user) {
return false;
}
Log::info('[' . strtoupper($event_name) . '] User #' . $user->id, $user->toArray());
return true;
}
示例7: createNewProperty
/**
* Store a new property
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function createNewProperty(Request $request, Authenticatable $user)
{
$this->validate($request, ['description' => 'required|string', 'image_url' => 'required|url']);
$newProperty = new VacationProperty($request->all());
$user->properties()->save($newProperty);
$request->session()->flash('status', "Property successfully created");
return redirect()->route('property-index');
}
示例8: validateCredentials
/**
* Validate a user against the given credentials.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials
* @return bool
*/
public function validateCredentials(Authenticatable $user, array $credentials)
{
if ($user instanceof CustomKeyAuthenticable) {
$method = 'get' . ucfirst($user->getAuthKeyName());
} else {
$method = 'getEmail';
}
return app('hash')->check($credentials['password'], $user->getAuthPassword()) && trim(strtolower($credentials['email'])) === trim(strtolower($user->{$method}()));
}
示例9: validateCredentials
/**
* Validate a user against the given credentials.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials
* @return bool
*/
public function validateCredentials(Authenticatable $user, array $credentials)
{
try {
$result = $this->application->authenticate($credentials['email'], $credentials['password']);
return $result->account->getHref() == $user->getAuthIdentifier();
} catch (\Exception $e) {
return false;
}
}
示例10: loadUserRelationships
/**
* Load the relationships for the given user.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return \Illuminate\Contracts\Auth\Authenticatable
*/
protected function loadUserRelationships($user)
{
$user->load('subscriptions');
if (Spark::usesTeams()) {
$user->load(['ownedTeams.subscriptions', 'teams.subscriptions']);
$user->currentTeam();
}
return $user;
}
示例11: configureTeamForNewUser
/**
* Attach the user to a team if an invitation exists, or create a new team.
*
* @param RegisterRequest $request
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return void
*/
protected function configureTeamForNewUser(RegisterRequest $request, $user)
{
if ($invitation = $request->invitation()) {
Spark::interact(AddTeamMember::class, [$invitation->team, $user]);
$invitation->delete();
} else {
Spark::interact(CreateTeam::class, [$user, ['name' => $request->team]]);
}
$user->currentTeam();
}
示例12: 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'];
$options = array();
if ($user instanceof User) {
$options['salt'] = $user->salt;
$options['byte_size'] = strlen($user->getAuthPassword());
}
return $this->hasher->check($plain, $user->getAuthPassword(), $options);
}
示例13: validatePassword
protected function validatePassword(Authenticatable $user, array $credentials)
{
$username = $this->getUsernameFromCredentials($credentials);
try {
$user->logIn($username, $credentials['password']);
} catch (ParseException $e) {
return false;
}
return true;
}
示例14: requestChangePassword
/**
* Generate a token for password change and saves it in
* the 'password_reminders' table with the email of the
* user.
*
* @param Authenticatable $user An existent user.
*
* @return string Password reset token.
*/
public function requestChangePassword(Authenticatable $user)
{
$email = $user->getReminderEmail();
$token = $this->generateToken();
$values = array('email' => $email, 'token' => $token, 'created_at' => new \DateTime());
$table = $this->getTable();
$this->app->make('db')->connection($user->getConnectionName())->table($table)->insert($values);
$this->sendEmail($user, $token);
return $token;
}
示例15: isMaxLimitOfCheckout
public function isMaxLimitOfCheckout()
{
$count = $this->user->checkoutHistories()->notReturned()->count();
if ($count >= 2) {
return false;
}
return true;
}