public async Task <IActionResult> Login(UserLoginDto user) { ServiceResponse <UserAuthDto> response = await _authrepo.Login(user.Email, user.Password); if (response.Status != ServiceResponseCodes.Created) { return(BadRequest(response)); } return(Ok(response)); }
public async Task <ActionResult <UserDto> > Login(UserLoginDto userLoginDto) { try { //get user by email var user = await _userRepository.GetUserByEmail(userLoginDto.Email); if (user == null) { return(Unauthorized(new RestError(HttpStatusCode.Unauthorized, new { Unauthorized = "Invalid email or password" }))); } //confirm password var passwordConfirmed = await _userRepository.ConfirmPassword(user, userLoginDto.Password); //Return a token if password confirmed if (passwordConfirmed) { var userDto = new UserDto { DisplayName = user.DisplayName, Token = _jwtGenerator.CreateToken(user), Username = user.UserName, Manager = user.Manager, Admin = user.Admin }; //get last timestamp for LastJobsiteVisited var lastJobsiteVisited = await _timestampRepository.GetUsersLastTimestamp(user); if (lastJobsiteVisited != null) { userDto.LastJobsiteVisited = _mapper.Map <TimestampWithBasicJobsiteInfoDto>(lastJobsiteVisited); } //check to see if currently clocked in at a jobsite var currentlyClockedin = await _timestampRepository.GetClockedInTimestamp(user); if (currentlyClockedin != null) { userDto.CurrentlyClockedIn = true; userDto.ClockedInTimestamp = _mapper.Map <TimestampClockedInBasicDto>(currentlyClockedin); } return(userDto); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Server Error: Failed to communicate with database.")); } //else return(Unauthorized(new RestError(HttpStatusCode.Unauthorized, new { Unauthorized = "Invalid email or password" }))); }
public async Task LoginUser_Returns401UnauthorizedWithInvalidData() { var requestBody = new UserLoginDto { UserName = "******", Password = Guid.NewGuid().ToString() }; var response = await _client.PostAsJsonAsync("/api/auth/login", requestBody); Assert.Equal(401, (int)response.StatusCode); }
public async Task <IActionResult> Login(UserLoginDto userLoginDto) { IDataResult <AccessToken> loginResult = _authService.Login(userLoginDto); if (!loginResult.Success) { return(BadRequest(loginResult)); } return(Ok(loginResult)); }
public async Task <IActionResult> Login(UserLoginDto dto) { ServiceResponse <string> res = await _repo.Login(dto.Username, dto.Password); if (res.Success == false) { return(BadRequest(res)); } return(Ok(res)); }
public async Task <SignInResult> Login(UserLoginDto creds) { var user = await _userManager.FindByEmailAsync(creds.Email); if (user == null) { return(SignInResult.Failed); } return(await _manager.PasswordSignInAsync(user.UserName, creds.Password, creds.RememberMe, true)); }
private static UserLoginDto GetAdminUserDto() { var dto = new UserLoginDto { UserName = "******", Password = "******", Environment = "TestGenForm" }; return(dto); }
public async Task <IActionResult> Login(UserLoginDto request) { var response = await _authRepository.Login( request.Username, request.Password); if (!response.IsSuccess) { return(BadRequest(response)); } return(Ok(response)); }
public ActionResult <UserReadDto> LoginUser(UserLoginDto userLoginDto) { User userResponse = CheckLoginPassword(userLoginDto); if (userResponse != null) { return(Ok(new { token = CreateToken(userResponse) })); } return(StatusCode(StatusCodes.Status200OK, new { status = "Error", message = "please check the information as it contains errors" })); }
public User CheckLoginPassword(UserLoginDto userLoginDto) { User userModel = _repositoryPerson.GetUserLogin(userLoginDto.Username); if (userModel != null && simpleHash.Verify(userLoginDto.Password, userModel.Password)) { return(userModel); } return(null); }
public ActionResult LoginCustomer(UserLoginDto userLoginDto) { var resultUser = _authService.LoginCustomer(userLoginDto); if (!resultUser.Success) { return(BadRequest(resultUser)); } return(Ok(resultUser)); }
public async Task <IActionResult> Login([FromBody] UserLoginDto userLoginDto) { var loginResult = await _accountServices.Login(userLoginDto); if (loginResult.Item1) { return(Ok(loginResult.Item3)); } return(BadRequest(loginResult.Item2)); }
public async Task <ActionResult> UserLogin(UserLoginDto userLogin) { var response = await _userAuth.Login(userLogin); if (!response.Success) { return(BadRequest(response)); } return(Ok(response)); }
public async Task <TokenDto> Login(UserLoginDto userLogin) { var user = await _authRepo.Login(userLogin); if (user != null) { return(CreateToken(user)); } return(null); }
public async Task <IActionResult> Login(UserLoginDto request) { ServiceResponse <string> response = await _authRepo.Login( request.Username, request.Password); if (!response.Success) { return(BadRequest(response)); } return(Ok(response)); }
public async Task <IActionResult> Login(UserLoginDto userLoginDto) { ServiceResponse <string> response = await authService.Login(userLoginDto); if (!response.Success) { return(BadRequest(response)); } return(Ok(response)); }
public IActionResult Login([FromBody] UserLoginDto data) { try { var result = userService.Login(data); return(Ok(result)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task <IActionResult> Login([FromBody] UserLoginDto userDto) { var token = await _identityService.LoginAsync(userDto) .ConfigureAwait(false); if (token == null) { return(Unauthorized()); } return(Ok(token)); }
public JsonResult Login(UserLoginDto dto) { var userData = new UserService().GetuserDetail(dto); if (userData == null) { return(Json("ERROR")); } UserHelper.CurrentUser = userData; return(Json("Ok")); }
public async Task <ActionResult <UserLogedDto> > LoginUser([FromForm] UserLoginDto userLoginDto) { try { return(Ok(await _accountService.LoginUserAsync(userLoginDto))); } catch (Exception ex) { _logger.Error(ex); return(StatusCode(StatusCodes.Status500InternalServerError, AccountControllerConstants.LoginUser_ErrorMessage)); } }
public async Task <IActionResult> Login(UserLoginDto objlogin) { ServiceResponse <LoginResponse> response = await _authRepo.Login( objlogin.username, objlogin.password ); if (!response.Success) { return(BadRequest(response)); } return(Ok(response)); }
public ActionResult <ApiResponse <UserDto> > Login(UserLoginDto item) { var response = new ApiResponse <UserDto>(); try { //UserDto usr = _mapper.Map<UserDto>(_userRepository.Find(c => c.Email == item.Email && c.Password == item.Password)); User usr = _userRepository.Find(u => u.Email == item.Email); if (usr != null) { if (_userRepository.VerifyPassword(usr.Password, item.Password)) { if (usr.Active == true) { if (usr.RolId == 1 || usr.RolId == 2) { response.Result = _mapper.Map <UserDto>(usr); } else { response.Success = false; response.Message = "Usuario no permitido"; } } else { response.Success = false; response.Message = "Cuenta inactiva"; } } else { response.Success = false; response.Message = "credenciales erroneas"; } } else { response.Success = false; response.Message = "Usuario no existe"; } } catch (Exception ex) { response.Result = null; response.Success = false; response.Message = "Internal server error"; _logger.LogError($"Something went wrong: { ex.ToString() }"); return(StatusCode(500, response)); } return(StatusCode(201, response)); }
public async Task <H5ResponseViewModel <UserSignViewModel> > UserSignInfo([FromBody] H5RequestViewModel Parameters) { var sysCode = _sys.CheckParameters(Parameters.data, "userverify"); H5ResponseViewModel <UserSignViewModel> response = null; sysCode = SysCode.Ok; UserSignViewModel result = new UserSignViewModel { Multiple = 1, Number = 1, state = true, }; if (sysCode == SysCode.Ok) { string token = Parameters.data.token; //token是否有效 bool isLog = _token.VerifyToken(token); if (isLog) { UserLoginDto userLogin = JsonHelper.DeserializeJsonToObject <UserLoginDto>(RedisHelper.StringGet($"{CacheKey.Token}{token}", RedisFolderEnum.token, RedisEnum.Five)); long userId = long.Parse(userLogin.Userid.ToString()); UserSignDto userSignDto = await _userTask.QueryUserSignAsync(userId); DateTime nowTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));//当前时间 if (userSignDto != null) { DateTime time = Convert.ToDateTime(userSignDto.Createtime.ToString("yyyy-MM-dd")); //用户最后一次签到时间 if (time == nowTime) { result.Multiple = userSignDto.Multiple; result.Number = userSignDto.Number; result.state = false; } else { if (TimeHelper.Dateday(nowTime, Convert.ToDateTime(time)) == 1) { result.Multiple = userSignDto.Multiple; result.Number = userSignDto.Number; result.state = true; } } } } else { sysCode = SysCode.TokenLose; } } response = new H5ResponseViewModel <UserSignViewModel>(sysCode, result); return(response); }
public async Task <(UserReturnDto userCredentials, string token)> Login(UserLoginDto loginCreds) { UserReturnDto loggedUser = await AuthecticateUser(loginCreds); if (loggedUser != null) { string token = GenerateToken(loggedUser); return(loggedUser, token); } return(null, null); }
public async Task <IActionResult> Login([FromBody] UserLoginDto userDto) { ServiceResponce <string> responce = await _authRepository.Login( userDto.Username, userDto.Password ); if (!responce.Success) { return(BadRequest(responce)); } return(Ok(responce)); }
public async Task <IActionResult> Login(UserLoginDto userToLogin) { var user = await _authRepo.Login(userToLogin.Username.ToLower(), userToLogin.Password); if (user != null) { var token = _authRepo.GenerateToken(user); return(Ok(new { token, user = _mapper.Map <UserDto>(user) })); } return(Unauthorized()); }
public bool Authenticate(UserLoginDto userInfo) { userInfo.Password = userInfo.Password.ToMD5Hash(); using (var db = new A77DbContext()) { if (db.User.Any(u => u.UserName.ToLower() == userInfo.UserName.ToLower() && userInfo.Password == u.Password)) { return(true); } } return(false); }
public UserLoginDto CheckUserAuthorization(LoginModel model) { UserLoginDto result = new UserLoginDto(); var received = _loginRepository.GetAllLogin(_dbContext) .Where(x => x.UserName == model.User_name && x.Password == model.Pass_word) .FirstOrDefault(); Mapper.CreateMap <LoginMst, UserLoginDto>(); result = Mapper.Map <LoginMst, UserLoginDto>(received); return(result); }
public void Login_UserNotExist() { var login = new UserLoginDto { Email = "*****@*****.**", Password = "******" }; _dataBase.Expect(x => x.FindBy(Arg <Expression <Func <UserTable, bool> > > .Is.Anything)).Return(new List <UserTable> ()); _mapper.Stub(x => x.Map(Arg <UserTable> .Is.Null)).Return(null); _service.Login(login); }
public async Task <IActionResult> Login(UserLoginDto userLoginDto) { ServiceResponse <string> response = await _authRepo.Login( userLoginDto.password, userLoginDto.email ); if (!response.Sucsses) { return(BadRequest(response)); } return(Ok(response)); }
private void DisplaySentLogin( Direction direction ) { using ( new Rock.Data.UnitOfWorkScope() ) { PersonService personService = new PersonService(); Person person = personService.Get( Int32.Parse( hfSendPersonId.Value ) ); if ( person != null ) { var mergeObjects = new Dictionary<string, object>(); mergeObjects.Add( "ConfirmAccountUrl", RootPath + "ConfirmAccount" ); var personDictionaries = new List<IDictionary<string, object>>(); var users = new List<IDictionary<string, object>>(); UserService userService = new UserService(); foreach ( UserLogin user in userService.GetByPersonId( person.Id ) ) { if ( user.ServiceType == AuthenticationServiceType.Internal ) { var userDictionary = new UserLoginDto( user ).ToDictionary(); userDictionary.Add( "ConfirmationCodeEncoded", user.ConfirmationCodeEncoded ); users.Add( userDictionary ); } } if ( users.Count > 0 ) { IDictionary<string, object> personDictionary = new PersonDto( person ).ToDictionary(); personDictionary.Add( "FirstName", person.FirstName ); personDictionary.Add( "Users", users.ToArray() ); personDictionaries.Add( personDictionary ); } mergeObjects.Add( "Persons", personDictionaries.ToArray() ); var recipients = new Dictionary<string, Dictionary<string, object>>(); recipients.Add( person.Email, mergeObjects ); Email email = new Email( Rock.SystemGuid.EmailTemplate.SECURITY_FORGOT_USERNAME ); email.Send( recipients ); } else ShowErrorMessage( "Invalid Person" ); } ShowPanel( 3 ); }