public object GetByName(string name, string password) { bool credentialIsValid = false; var user = userReadOnlyUseCase.GetByName(name, password); if (user != null && !string.IsNullOrEmpty(user.Name)) { var baseUser = userReadOnlyUseCase.GetByName(user.Name, user.Password); credentialIsValid = (baseUser != null && user.Name == baseUser.Name && user.Password == baseUser.Password && user.Email == baseUser.Email && user.Birthday == baseUser.Birthday && user.CreatedAt == baseUser.CreatedAt && user.UpdatedAt == baseUser.UpdatedAt && user.UpdatedAt == baseUser.UpdatedAt && user.UserType == baseUser.UserType && user.Id == baseUser.Id ); } if (credentialIsValid) { ClaimsIdentity identity = new ClaimsIdentity( new GenericIdentity(user.Name, "Name"), new [] { new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString("N")), new Claim(JwtRegisteredClaimNames.UniqueName, user.Name) } ); DateTime createDate = DateTime.Now; DateTime expiration = createDate + TimeSpan.FromSeconds(tokenConfiguration.Seconds); var handler = new JwtSecurityTokenHandler(); string token = CreateToken(identity, createDate, expiration, handler); return(SuccessObject(createDate, expiration, token)); } else { return(ExceptionObject()); } }
public Domain.Entities.User GetByName(string name, string password) { return(userReadOnlyUseCase.GetByName(name, password)); }