示例#1
0
 public BaseResponse <AuthenticateViewModel> AuthenticateByGoogle(GoogleAuthenticateModel googleAuthenticateModel)
 {
     try
     {
         var syncSucceed = SyncUserProfileIfNotExisted(googleAuthenticateModel.Email, googleAuthenticateModel.GivenName, googleAuthenticateModel.FamilyName);
         if (syncSucceed)
         {
             var user = LoadRelated(FindByEmail(googleAuthenticateModel.Email));;
             if (user == null)
             {
                 return(BaseResponse <AuthenticateViewModel> .NotFound());
             }
             var authResponseModel = GetAuthResponseModel(user);
             if (authResponseModel != null)
             {
                 return(BaseResponse <AuthenticateViewModel> .Success(authResponseModel));
             }
         }
         return(BaseResponse <AuthenticateViewModel> .NotFound());
     }
     catch (Exception ex)
     {
         return(BaseResponse <AuthenticateViewModel> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
     }
 }
示例#2
0
        public IActionResult GoogleAuth([FromBody] GoogleAuthenticateModel authModel)
        {
            if (!ModelState.IsValid)
            {
                return(Ok(BaseResponse <string> .BadRequest()));
            }
            var result = _authervice.AuthenticateByGoogle(authModel);

            return(Ok(result));
        }
        public BaseResponse <AuthenticateViewModel> GoogleAuthenticate(GoogleAuthenticateModel googleAuthenticateModel, string host = "", string api = "", string token = "")
        {
            var requestModel = new ApiRequestModel()
            {
                Token       = token,
                Host        = host,
                Api         = string.IsNullOrEmpty(api) ? "api/GoogleAuth" : api,
                RequestBody = googleAuthenticateModel
            };
            var response = Post <AuthenticateViewModel>(requestModel);

            return(response);
        }
示例#4
0
        public async Task <IActionResult> GoogleLogin(GoogleAuthenticateModel model)
        {
            if (ModelState.IsValid)
            {
                var result = _authenticateRequestService.GoogleAuthenticate(model);
                if (result.IsSuccessStatusCode)
                {
                    await SignInAsync(result.ResponseData);

                    return(Ok(true));
                }
                return(Ok(BaseResponse <string> .BadRequest(result.Message)));
            }
            return(Ok(BaseResponse <string> .BadRequest()));
        }