作者:defenestrato
项目:groi
/**
* 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);
}
作者:larasit
项目:larasit
/**
* 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'];
}
作者:ssddanbrow
项目:bookstac
/**
* 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();
}
}
作者:ahmadmui
项目:wp_employe
/**
* 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());
}
作者:h3r2o
项目:shibbolet
/**
* @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;
}
作者:agine
项目:login-activit
/**
* 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;
}
作者:TwilioDevE
项目:airtng-larave
/**
* 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');
}
作者:atrauzz
项目:laravel-doctrin
/**
* 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}()));
}
作者:stormpat
项目:stormpath-laravel-auth-drive
/**
* 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;
}
}
作者:defenestrato
项目:groi
/**
* 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;
}
作者:defenestrato
项目:groi
/**
* 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();
}
作者:drawmyattentio
项目:expaut
/**
* 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);
}
作者:parzipha
项目:pars
protected function validatePassword(Authenticatable $user, array $credentials)
{
$username = $this->getUsernameFromCredentials($credentials);
try {
$user->logIn($username, $credentials['password']);
} catch (ParseException $e) {
return false;
}
return true;
}
作者:joshl
项目:confid
/**
* 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;
}
作者:ReyRodrigue
项目:spar
/**
* Get all of the pending invitations for the user.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getPendingInvitationsForUser($user)
{
$invitations = $user->invitations()->with('team.owner')->get();
foreach ($invitations as $invite) {
$invite->setVisible(['id', 'team']);
$invite->team->setVisible(['name', 'owner']);
$invite->team->owner->setVisible(['name']);
}
return $invitations;
}
作者:mastashake0
项目:laravel-spark-archiv
/**
* Create the subscription on Stripe.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return void
*/
protected function createSubscriptionOnStripe(Request $request, $user)
{
$plan = Spark::plans()->find($request->plan);
$subscription = $user->subscription($plan->id);
if ($plan->hasTrial()) {
$subscription->trialFor(Carbon::now()->addDays($plan->trialDays));
}
if ($request->coupon) {
$subscription->withCoupon($request->coupon);
}
$subscription->create($request->stripe_token, ['email' => $user->email]);
}
作者:Rareloo
项目:laravel-auth-toke
/**
* Creates an auth token for user.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return \TAppleby\AuthToken\AuthToken|false
*/
public function create(Authenticatable $user)
{
if ($user == null || $user->getAuthIdentifier() == null) {
return false;
}
$token = $this->generateAuthToken();
$token->setAuthIdentifier($user->getAuthIdentifier());
$t = new \DateTime();
$insertData = array_merge($token->toArray(), array('created_at' => $t, 'updated_at' => $t));
$this->db()->insert($insertData);
return $token;
}
作者:defenestrato
项目:groi
/**
* Validate that the maximum number of teams hasn't been exceeded.
*
* @param \Illuminate\Validation\Validator $validator
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return void
*/
protected function validateMaximumTeamsNotExceeded($validator, $user)
{
if (!($plan = $user->sparkPlan())) {
return;
}
if (is_null($plan->teams)) {
return;
}
if ($plan->teams <= $user->ownedTeams()->count()) {
$validator->errors()->add('name', 'Please upgrade your subscription to create more teams.');
}
}
作者:TwilioDevE
项目:airtng-larave
/**
* Store a new reservation
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function create(Client $client, Request $request, Authenticatable $user, $id)
{
$this->validate($request, ['message' => 'required|string']);
$property = VacationProperty::find($id);
$reservation = new Reservation($request->all());
$reservation->respond_phone_number = $user->fullNumber();
$reservation->user()->associate($property->user);
$property->reservations()->save($reservation);
$this->notifyHost($client, $reservation);
$request->session()->flash('status', "Sending your reservation request now.");
return redirect()->route('property-show', ['id' => $property->id]);
}
作者:vitalysemeno
项目:oaut
/**
* Handle user logged in.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
*
* @return bool|null
*/
public function handle(Authenticatable $user)
{
$social = $this->session->get('authentication.social.oauth');
if (is_null($social)) {
return;
}
$model = User::where('provider', '=', $social['provider'])->where('uid', '=', $social['user']->getId())->first();
if (is_null($model)) {
return;
}
$model->setAttribute('user_id', $user->getAuthIdentifier());
$model->save();
return true;
}