Skip to content

Commit

Permalink
Merge pull request #131 from SWD392-Domus/hotfix/add-user-info-google
Browse files Browse the repository at this point in the history
[Hotfix][Duy] Return user information when logging in with Google
  • Loading branch information
duykasama authored Mar 17, 2024
2 parents 6b7c6c1 + 8b6ae4c commit 4212449
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Domus.Service/Implementations/GoogleOAuthService.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.IdentityModel.Tokens.Jwt;
using System.Net;
using AutoMapper;
using Domus.Common.Constants;
using Domus.Common.Exceptions;
using Domus.Common.Extensions;
using Domus.Common.Helpers;
using Domus.Common.Settings;
using Domus.DAL.Interfaces;
using Domus.Domain.Dtos;
using Domus.Domain.Entities;
using Domus.Service.Constants;
using Domus.Service.Exceptions;
Expand All @@ -27,14 +29,16 @@ public class GoogleOAuthService : IGoogleOAuthService
private readonly IUnitOfWork _unitOfWork;
private readonly IJwtService _jwtService;
private readonly IEmailService _emailService;
private readonly IMapper _mapper;

public GoogleOAuthService(IConfiguration configuration, UserManager<DomusUser> userManager, IUnitOfWork unitOfWork, IJwtService jwtService, IEmailService emailService)
public GoogleOAuthService(IConfiguration configuration, UserManager<DomusUser> userManager, IUnitOfWork unitOfWork, IJwtService jwtService, IEmailService emailService, IMapper mapper)
{
_configuration = configuration;
_userManager = userManager;
_unitOfWork = unitOfWork;
_jwtService = jwtService;
_emailService = emailService;
_mapper = mapper;
}

public async Task<ServiceActionResult> LoginAsync(OAuthRequest request)
Expand Down Expand Up @@ -83,7 +87,8 @@ public async Task<ServiceActionResult> LoginAsync(OAuthRequest request)
}
};

return new ServiceActionResult(true) { Data = authResponse };
var returnedUser = _mapper.Map<DtoDomusUser>(user);
return new ServiceActionResult(true) { Data = new { userInfo = returnedUser, token = authResponse } };
}

private async Task<DomusUser> CreateNewUserAsync(string email, string emailVerified, string fullName, string picture)
Expand Down

0 comments on commit 4212449

Please sign in to comment.