コード例 #1
0
        public string[] Login(string name, string pwd)
        {
            var    db     = CoreDBContext.GetContext();
            string md5Pwd = CryptHelper.MD5(pwd);

            var entity = (from x in db.Set <TEntity>()
                          where x.UserName == name &&
                          x.UserPwd == md5Pwd
                          select x).FirstOrDefault();

            if (entity != null)
            {
                if (string.IsNullOrWhiteSpace(entity.RoleName))
                {
                    return(new string[] { "LogOn", "Home" });
                }

                CookieHelper.Clear();
                CookieHelper.SetCookie("UserId", entity.ID.ToString());
                CookieHelper.SetCookie("UserName", entity.UserName);
                CookieHelper.SetCookie("RoleName", entity.RoleName);
                this.ExtraCookies(entity);
                FormsAuthentication.SetAuthCookie(entity.UserName, false);

                //return new string[]{ action, controller }
                return(RedirectToAction());
            }

            return(null);
        }
コード例 #2
0
        public void Quit()
        {
            LogService.Write(new Instart.Models.Log
            {
                Title    = $"{LoginUser.UserName}退出系统",
                UserId   = LoginUser.UserId,
                UserName = LoginUser.UserName,
                Type     = Instart.Models.Enums.EnumOperType.Other,
            });

            Session[WebAppSettings.SessionName] = null;
            CookieHelper.Clear(WebAppSettings.CookieName);
        }
コード例 #3
0
 // ReSharper disable TooManyDependencies
 public DropBoxSourceViewModel(INetworkHelper network, IDropBoxHelper dropboxHelper, IDropboxFactory dropboxFactory, bool shouldAuthorise)
 // ReSharper restore TooManyDependencies
 {
     VerifyArgument.AreNotNull(new Dictionary <string, object> {
         { "network", network }, { "dropboxHelper", dropboxHelper }, { "dropboxFactory", dropboxFactory }
     });
     _network        = network;
     _dropboxFactory = dropboxFactory;
     DropBoxHelper   = dropboxHelper;
     CookieHelper.Clear();
     if (shouldAuthorise)
     {
         Authorise();
     }
 }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CurrentUser == null)
            {
                Login();
            }
            if (RequestHelper.IsPostBack(Request))
            {
                string          oldPwd     = Request["oldpassword"].Trim();
                string          newPwd     = Request["password"].Trim();
                string          confirmPwd = Request["confirm"].Trim();
                UsersBLL        usersBLL   = new UsersBLL();
                ChangePwdResult result     = usersBLL.ChangePwd(CurrentUser.userId, oldPwd, newPwd, confirmPwd);
                switch (result)
                {
                case ChangePwdResult.旧密码错误:
                    msg = "旧密码错误";
                    break;

                case ChangePwdResult.两次输入密码不一致:
                    msg = "两次输入密码不一致";
                    break;

                case ChangePwdResult.修改成功:
                    msg = "修改成功";
                    Session.Clear();
                    CookieHelper.Clear();
                    Response.Redirect("../account/Login.aspx");
                    break;

                case ChangePwdResult.用户不存在:
                    msg = "用户不存在";
                    break;

                default:
                    break;
                }
            }
        }
コード例 #5
0
 public ManageOAuthSourceViewModel(IManageOAuthSourceModel updateManager, Task <IRequestServiceNameViewModel> requestServiceNameViewModel)
     : base("OAuth")
 {
     if (updateManager == null)
     {
         throw new ArgumentNullException(nameof(updateManager));
     }
     if (requestServiceNameViewModel == null)
     {
         throw new ArgumentNullException(nameof(requestServiceNameViewModel));
     }
     _updateManager = updateManager;
     RequestServiceNameViewModel = requestServiceNameViewModel;
     Header = Resources.Languages.Core.OAuthSourceNewHeaderLabel;
     Types  = new List <string>
     {
         "Dropbox"
     };
     SelectedOAuthProvider = Types[0];
     CookieHelper.Clear();
     HasAuthenticated = false;
     SetupCommands();
 }
コード例 #6
0
 public void Clear()
 {
     cookie.Clear();
 }
コード例 #7
0
 public void Quit()
 {
     Session[WebAppSettings.SessionName] = null;
     CookieHelper.Clear(WebAppSettings.CookieName);
 }
コード例 #8
0
    protected void RegisterButton_Click(object sender, EventArgs e)
    {
        try
        {
            bool activationRequired = ConstantHelper.ActivationRequired;

            RegisterUserResponse registerUserResponse = null;
            var facade = Services.Get <Facade>();
            {
                registerUserResponse = facade.RegisterUser(Email.Text, Password.Text, Email.Text, activationRequired);
            }

            if (registerUserResponse != null)
            {
                if (activationRequired)
                {
                    MailManager.SendSignupMail(Email.Text.Trim(), Password.Text.Trim(), activationRequired, registerUserResponse.UnlockKey);
                    CookieHelper.Clear();
                    Response.Redirect("~/Confirm.aspx");
                }
                else
                {
                    FormsAuthentication.RedirectFromLoginPage(Email.Text, RememberMeCheckbox.Checked);
                    MailManager.SendSignupMail(Email.Text.Trim(), Password.Text.Trim(), activationRequired, string.Empty);
                    Response.Redirect("~/Default.aspx");
                }
            }
            else
            {
                InvalidLoginLabel.Visible = true;
            }

            // -- Workflow way. Obselete.
            //var response = WorkflowHelper.Run<UserRegistrationWorkflow,UserRegistrationWorkflowRequest,UserRegistrationWorkflowResponse>(
            //                new UserRegistrationWorkflowRequest { Email = Email.Text, RequestedUsername = Email.Text, Password = Password.Text, IsActivationRequired = activationRequired, UserName = Profile.UserName }
            //            );

            //if (response != null)
            //{
            //    if (activationRequired)
            //    {
            //        MailManager.SendSignupMail(Email.Text.Trim(), Password.Text.Trim(), activationRequired, response.UnlockKey);
            //        CookieHelper.Clear();
            //        Response.Redirect("~/Confirm.aspx");
            //    }
            //    else
            //    {
            //        FormsAuthentication.RedirectFromLoginPage( Email.Text, RememberMeCheckbox.Checked );
            //        MailManager.SendSignupMail(Email.Text.Trim(), Password.Text.Trim(), activationRequired, string.Empty);
            //        Response.Redirect( "~/Default.aspx" );
            //    }
            //}
            //else
            //{
            //    InvalidLoginLabel.Visible = true;
            //}
        }
        catch (Exception x)
        {
            Debug.WriteLine(x);
            InvalidLoginLabel.Visible = true;
            InvalidLoginLabel.Text    = x.Message;
        }
    }