public static Task <JwtLoginCredentials> GetInputAsync(string title) { var context = GetContext(); var tcs = new TaskCompletionSource <JwtLoginCredentials>(); var result = new JwtLoginCredentials(); AlertDialog dialog = null; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetTitle(title); var viewInflated = LayoutInflater.From(context).Inflate(Resource.Layout.login_view, null, false); var userInput = viewInflated.FindViewById <AppCompatEditText>(Resource.Id.input_user); var passwordInput = viewInflated.FindViewById <AppCompatEditText>(Resource.Id.input_password); builder.SetView(viewInflated); builder.SetOnCancelListener(new DialogInterfaceOnCancelListener(() => tcs.TrySetResult(null))); builder.SetOnDismissListener(new DialogInterfaceOnDismissListener(() => tcs.TrySetResult(null))); builder.SetPositiveButton(Android.Resource.String.Ok, (sender, args) => { result.User = userInput.Text; result.Password = passwordInput.Text; tcs.TrySetResult(result); dialog.Dismiss(); }); builder.SetNegativeButton(Android.Resource.String.Cancel, (sender, args) => { tcs.TrySetResult(null); dialog.Cancel(); }); dialog = builder.Show(); return(tcs.Task); }
public async Task <ActionResult <JwtAuthenticationResult> > Authenticate([FromBody] JwtLoginCredentials model) { if (model == null) { return(StatusCode((int)HttpStatusCode.ExpectationFailed)); } _logger.LogInformation("User {Name} is authenticating", model.User); var authentication = await _jwtTokenService.CreateAuthenticationAsync(model.User, model.Password); if (authentication.InvalidCredentials) { return(StatusCode((int)HttpStatusCode.Unauthorized)); } return(Json(authentication)); }
private async Task <LoginResponse> GetLoginResponseAsync(GrpcApplicationAgent grpcApplicationAgent, JwtLoginCredentials input) { try { return(await grpcApplicationAgent.FullDesktopClient.LoginAsync(new LoginRequest() { User = input.User, Password = input.Password })); } catch (RpcException exception) { Log.Error(exception, "Login error"); return(new LoginResponse() { InvalidCredentials = true }); } }