/**
  * @param array $params
  * @return mixed
  * @throws BadRequestException
  */
 public function login($params = array())
 {
     $defaults = array('email' => $email = null, 'password' => $password = null);
     $rules = array('email' => array('required', 'email', 'exists:users,email,login_type,' . User::LOGIN_TYPE_PASSWORD . ',deleted_at,NULL'), 'password' => array('required'));
     $params = $this->validateParams($defaults, $params, $rules);
     extract($params);
     if (!$this->api->guard->attempt(array('email' => $email, 'password' => $password, 'login_type' => User::LOGIN_TYPE_PASSWORD, 'deleted_at' => null))) {
         throw new BadRequestException("Your credentials are incorrect. Please try again.");
     }
     $user = $this->api->user();
     $access_token = AccessToken::make($user);
     return AccessToken::where('token', $access_token->token)->firstOrFail();
 }