Example #1
0
        public async Task <IActionResult> LoginSocial([FromBody]  LoginSocialRequest loginSocialRequest)
        {
            var result = await _accountService.LoginSocialAsync(loginSocialRequest);

            HttpContext.Response.Headers["Authorization"] = "Bearer " + result.accessToken;
            HttpContext.Response.Headers["RefreshToken"]  = result.refreshToken;
            HttpContext.Response.Headers["Access-Control-Expose-Headers"] = "Authorization, RefreshToken";
            var user = _mapper.Map <UserResponse>(result.user);

            return(Ok(new ApiOkResponse(user)));
        }
Example #2
0
        public async Task <(User user, string accessToken, string refreshToken)> LoginSocialAsync(LoginSocialRequest loginSocialRequest)
        {
            FirebaseToken decodedToken = await FirebaseAuth.DefaultInstance.VerifyIdTokenAsync(loginSocialRequest.Token);

            string     uid        = decodedToken.Uid;
            UserRecord userRecord = await FirebaseAuth.DefaultInstance.GetUserAsync(uid);

            var    pwd      = new Password();
            string password = pwd.Next();
            User   user     = await SignUpAsync(new SignUpRequest { FullName = userRecord.DisplayName, Email = userRecord.Email, Password = password, Social = true });

            Tokens tokens = await SetTokenAsync(user);

            return(user, tokens.Token, tokens.RefreshToken);
        }