/**
  *	Authenticate a registered user, with its email and password
  */
 public function authenticate()
 {
     $input = Input::all();
     $validator = Validator::make($input, User::getAuthRules());
     if ($validator->passes()) {
         $user = User::where('email', '=', $input['email'])->first();
         if (!$user instanceof User) {
             return ApiResponse::json("User is not registered.");
         }
         if (Hash::check($input['password'], $user->password)) {
             $device_id = Input::has('device_id') ? $input['device_id'] : '';
             $device_type = Input::has('device_type') ? $input['device_type'] : '';
             $device_token = Input::has('device_token') ? $input['device_token'] : '';
             $token = $user->login($device_id, $device_type, $device_token);
             Log::info('<!> Device Token Received : ' . $device_token . ' - Device ID Received : ' . $device_id . ' for user id: ' . $token->user_id);
             Log::info('<!> Logged : ' . $token->user_id . ' on ' . $token->device_os . '[' . $token->device_id . '] with token ' . $token->key);
             $token->user = $user->toArray();
             $token = ApiResponse::json($token, '202');
         } else {
             $token = ApiResponse::json("Incorrect password.", '412');
         }
         return $token;
     } else {
         return ApiResponse::validation($validator);
     }
 }