Esempio n. 1
0
        void OnResetPassword(object sender, EventArgs e)
        {
            Debug.Assert(EnablePasswordReset);

            if (RequiresQuestionAndAnswer)
            {
                ResetWithQuestionDialog dialog = new ResetWithQuestionDialog(ServiceAddress, ApplicationName, UserName);
                dialog.ShowDialog();
            }
            else
            {
                IPasswordManager passwordManager = UserManagerProviderFactory.CreatePasswordManager(); // new AspNetSqlProviderService(ServiceAddress);
                string           newPassword     = null;
                try
                {
                    newPassword = passwordManager.ResetPassword(ApplicationName, UserName);
                    Clipboard.SetText(newPassword);
                }
                catch (SoapException exception)
                {
                    if (exception.Message.Contains("The user account has been locked out"))
                    {
                        MessageBox.Show("The user account has been locked out", "Credentials Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    throw;
                }
                MessageBox.Show("Generated password: "******" " + Environment.NewLine + "The password is avaiable on the clipboard as well.", "Credentials Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 2
0
        public Mutation(IUserService userService, IPasswordManager passwordManager, IEmailVerificationService verification, ISessionService sessionService, IHttpContextAccessor contextAccessor)
        {
            FieldAsync <NonNullGraphType <UserType>, User>("register",
                                                           arguments: new QueryArguments(RegisterInputType.BuildArgument()),
                                                           resolve: x => userService.Create(x.GetArgument <RegisterInput>("input")));

            FieldAsync <NonNullGraphType <StringGraphType>, string>("refreshToken",
                                                                    resolve: x => sessionService.Refresh(contextAccessor.MustGetBearerToken()));

            FieldAsync <NonNullGraphType <TokensType>, LoginSuccessResponse>("login",
                                                                             resolve: x => sessionService.Login(contextAccessor.GetLoginRequest()));

            FieldAsync <NonNullGraphType <UserType>, User>("verifyEmail",
                                                           arguments: new QueryArguments(VerifyEmailInputType.BuildArgument()),
                                                           resolve: x => verification.ConfirmEmail(x.GetArgument <VerifyEmailInput>("input")));

            FieldAsync <NonNullGraphType <ResultType>, Result>("sendActivationEmail",
                                                               arguments: new QueryArguments(new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "login"
            }),
                                                               resolve: x => verification.SendActivationEmail(x.GetArgument <string>("login")));

            FieldAsync <NonNullGraphType <ResultType>, Result>("requestPasswordReset",
                                                               arguments: new QueryArguments(new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "login"
            }),
                                                               resolve: x => passwordManager.RequestPasswordReset(x.GetArgument <string>("login")));

            FieldAsync <NonNullGraphType <UserType>, User>("changePassword",
                                                           arguments: new QueryArguments(ChangePasswordInput.BuildArgument()),
                                                           resolve: x => passwordManager.ChangePassword(contextAccessor.GetUserId(), x.GetArgument <ChangePasswordRequest>("input"))).Authorize();

            FieldAsync <NonNullGraphType <UserType>, User>("resetPassword",
                                                           arguments: new QueryArguments(ResetPasswordInput.BuildArgument()),
                                                           resolve: x => passwordManager.ResetPassword(x.GetArgument <ResetPasswordRequest>("input")));
        }