public async Task <IActionResult> Login(Credentials credentials) { if (!ModelState.IsValid) { return(View(credentials)); } var fbUser = await _firebaseAuthService.Login(credentials); if (fbUser == null) { ModelState.AddModelError(string.Empty, "Invalid email or password."); return(View(credentials)); } var userProfile = _userProfileRepository.GetByFirebaseUserId(fbUser.FirebaseUserId); if (userProfile == null) { ModelState.AddModelError(string.Empty, "Unable to Login."); return(View(credentials)); } await LoginToApp(userProfile); return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult <ApiResponse <LoginStatus> > > Login([FromBody] Login request) { try { var result = await firebaseAuthService.Login(request); return(Ok(new ApiResponse <LoginStatus>(result))); } catch (Exception) { return(StatusCode((int)HttpStatusCode.Unauthorized, RequestResponse.BadRequest(string.Empty))); } }