public void Register(User user) { try { var isExistUsername = _userRepo.IsExist(x => x.username == user.username); var isExistsEmail = _userRepo.IsExist(x => x.email == user.email); if (isExistUsername) { throw new AlreadyExistException("Username already exist."); } else if (isExistsEmail) { throw new AlreadyExistException("Email already exist."); } else { var encriptedPasword = EncryptExtension.EncryptMD5(user.password); user.password = encriptedPasword; _userRepo.Add(user); } } catch (Exception ex) { throw ex; } }
public Task <LoginResponse> Handle(LoginQuery request, CancellationToken cancellationToken) { var loginResponse = new LoginResponse(); var error = ErrorCode.UsuarioNoResgistrado; var respuesta = (from A in _context.Personas where A.RUT == request.Rut select A).FirstOrDefault(); if (respuesta != null) { if (EncryptExtension.DesEncriptar(request.Password) == EncryptExtension.DesEncriptar(respuesta.PASSWORD)) { loginResponse.Name = $"{respuesta.NOMBRES} {respuesta.AP_PATERNO} {respuesta.AP_MATERNO}"; loginResponse.IdPer = respuesta.ID_PER; error = ErrorCode.None; } else { error = ErrorCode.PasswordIncorrecta; } } loginResponse.ERROR = error; return(Task.FromResult(loginResponse)); }
public bool Login(string username, string password) { var encriptedPasword = EncryptExtension.EncryptMD5(password); return(_userRepo.IsExist(x => x.username == username && x.password == encriptedPasword)); }