public function login(Request $request)
 {
     $user = User::where('email', $request->input('email'))->first();
     if (AuthService::attemptLogin($user, $request->input('password'))) {
         return response(['user' => $user, 'auth_token' => SecurityService::generateToken($user)]);
     }
     return response('Invalid credentials.')->header('Status', 401);
 }
 public static function attemptLogin($user, $password)
 {
     return $user && SecurityService::checkPassword($password, $user->password);
 }