Exemplo n.º 1
0
        public async Task <ManagerAuthViewModel> AuthenticateAsync(string email, string password)
        {
            var passwordHashed = AuthenticateHelper.HashPassword(password);
            var manager        = await _managerRepository.AuthenticateManagerAsync(email, passwordHashed);

            if (manager == null)
            {
                return(null);
            }
            var claims = new Claim[]
            {
                new Claim(ClaimTypes.NameIdentifier, manager.Id.ToString()),
                new Claim(ClaimTypes.Name, email),
                new Claim(ClaimTypes.Role, manager.Role_Name),
                new Claim("Scope", "Manager")
            };
            var jwtResult = _jwtAuthManager.GenerateTokens(email, claims, DateTime.Now);

            return(new ManagerAuthViewModel
            {
                Manager = manager,
                JwtResult = jwtResult
            });
        }
Exemplo n.º 2
0
 public async Task <ManagerViewModel> AuthenticateManagerAsync(string email, string passwordHash)
 {
     return(await _managerRepository.AuthenticateManagerAsync(email, passwordHash));
 }