public async Task <AuthenticationResult> LoginAsync(string userName, string password) { try { var user = await _usersService.FindByUsernameAsync(userName); if (user == null) { return(new AuthenticationResult { Errors = new[] { "User with this Username does not exist" } }); } var validPassword = await _usersService.CheckPasswordAsync(user, password); if (!validPassword) { return(new AuthenticationResult { Errors = new[] { $"Incorrect password!" } }); } var anmId = user.id; var userType = user.userType; if (userType.ToUpper() == "ANM") { var checkmobile = await _usersService.CheckWebLogin(anmId, userName); var allow = checkmobile.allow; var msg = checkmobile.msg; if (allow == false) { return(new AuthenticationResult { Errors = new[] { msg } }); } } _usersData.AddLoginDetails(user.id, userName, "", "PC"); return(GenerateAuthenticationResult(user)); } catch (Exception e) { return(new AuthenticationResult { Success = false, Token = null, Errors = new[] { e.Message } }); } }