public async Task <bool> LoginAsync(string username, string password) { var bindResult = await _ldapService.TestCredentialsAsync(username, password); if (!bindResult) { return(false); } else { await _sessionStorageService.SetItemAsync("loggedIn", bindResult); await _sessionStorageService.SetItemAsync("ldapCredentials", new LdapCredential() { UserName = _cryptService.EncryptString(username), Password = _cryptService.EncryptString(password) }); return(true); } }
public async Task <ActionResult <User> > Register(RegisterEntity registerEntity) { bool isEmailUsed = await _repository.IsEmailUsed(_cryptService.EncryptString(registerEntity.Email)); if (isEmailUsed) { return(BadRequest("Email already used!")); } User user = new User { FirstName = _cryptService.EncryptString(registerEntity.FirstName), LastName = _cryptService.EncryptString(registerEntity.LastName), Email = _cryptService.EncryptString(registerEntity.Email), Password = _cryptService.EncryptString(registerEntity.Password) }; await _repository.AddUser(user); return(CreatedAtAction("GetById", new { id = user.Id }, user)); }