public function check_login() { if (!DataSource::check_login($this->user_id, $this->password())) { $this->password = null; $this->save(); } }
public function postLogin(Request $request) { $this->validate($request, ['user_id' => 'required', 'password' => 'required']); $credentials = $request->only('user_id', 'password'); $redirect = $this->redirectPath(); $lock_new_users = true; $try = false; if (User::find($credentials['user_id'])) { // The user exists $try = true; } else { if ($lock_new_users) { return redirect('/locked'); } else { if (($person = Person::find($credentials['user_id'])) && DataSource::check_login($credentials['user_id'], $credentials['password'])) { // The ID exists and details are correct, but there isn't an account for it. Make one. $user = User::create(['user_id' => $credentials['user_id'], 'name' => $person->name, 'password' => \Crypt::encrypt($credentials['password']), 'is_queued' => true]); \Queue::push(new PrepareUser($user)); $redirect = '/setup'; $try = true; } } } if ($try && Auth::attempt($credentials, $request->has('remember'))) { return redirect()->intended($redirect); } return redirect($this->loginPath())->withInput($request->only('user_id', 'remember'))->withErrors(['user_id' => $this->getFailedLoginMessage()]); }
function profileImage($id, $width = 128, $height = 128) { $image = \Cache::rememberForever("userprofile-{$id}-{$width}-x-{$height}", function () use($id, $width, $height) { $img = DataSource::keystone_exec("_layouts/StPeters.Keystone/_shared/avatarhandler.ashx?id={$id}&w={$width}&h={$height}"); return $img; }); return \Response::make($image, 200, array('content-type' => 'image/jpg')); }
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; }