コード例 #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtUserID.Text.Trim() == string.Empty)
            {
                lblErrMessage.Text = CommonMessages.MSG_LOG_IN_EMPTY_EMAIL;
                return;
            }

            if (txtPWD.Text.Trim() == string.Empty)
            {
                lblErrMessage.Text = CommonMessages.MSG_LOG_IN_EMPTY_PASSWORD;
                return;
            }


            try
            {
                GlobalUsersBLL globalUsersBLL    = new GlobalUsersBLL();
                var            globalUserDetails = globalUsersBLL.AuthenticateUser(txtUserID.Text.Trim(), EncryptString(txtPWD.Text.Trim()));

                if (globalUserDetails != null)
                {
                    int appUserID = globalUsersBLL.GetApplicationUserByUser(globalUserDetails.UserID, ABCLogisticsApp.TMS);

                    if (appUserID > 0)
                    {
                        Session["GlobalUserID"] = globalUserDetails.UserID.ToString();
                        Session["UserName"]     = globalUserDetails.FirstName + " " + globalUserDetails.LastName;
                        Session["FirstName"]    = globalUserDetails.FirstName;
                        Session["LastName"]     = globalUserDetails.LastName;
                        Session["RoleID"]       = globalUserDetails.RoleID.ToString();
                        Session["UserEmail"]    = globalUserDetails.Email;
                        Session["Password"]     = globalUserDetails.Password;
                        Session["AppUserID"]    = appUserID.ToString();

                        if (cbRememberMe.Checked == true)
                        {
                            RememberUser(txtUserID.Text.Trim());
                        }
                        Response.Redirect("~/home", false);
                    }
                    else
                    {
                        lblErrMessage.Text = CommonMessages.ERROR_GLOBAL_NO_APPLICATION_ACCESS;
                    }
                }
                else
                {
                    lblErrMessage.Text = CommonMessages.ERROR_GLOBAL_ACCOUNT_NOT_FOUND;
                }
            }
            catch (Exception ex)
            {
                lblErrMessage.Text    = (new GlobalErrorLogsBLL()).LogGlobalError(ex, "TMS - LogIn - btnLogin_Click");
                lblErrMessage.Visible = true;
            }
        }
コード例 #2
0
        private void LogInUser(string email, Guid identifier)
        {
            try
            {
                GlobalUsersBLL globalUsersBLL    = new GlobalUsersBLL();
                var            globalUserDetails = globalUsersBLL.AuthenticateUserByOpenID(email, identifier);
                if (globalUserDetails != null)
                {
                    int appUserID = globalUsersBLL.GetApplicationUserByUser(globalUserDetails.UserID, ABCLogisticsApp.TMS);

                    if (appUserID > 0)
                    {
                        Session["GlobalUserID"] = globalUserDetails.UserID.ToString();
                        Session["UserName"]     = globalUserDetails.FirstName + " " + globalUserDetails.LastName;
                        Session["FirstName"]    = globalUserDetails.FirstName;
                        Session["LastName"]     = globalUserDetails.LastName;
                        Session["RoleID"]       = globalUserDetails.RoleID.ToString();
                        Session["UserEmail"]    = globalUserDetails.Email;
                        Session["Password"]     = globalUserDetails.Password;
                        Session["AppUserID"]    = appUserID.ToString();
                        Session["GoogleID"]     = identifier;

                        if (cbRememberMe.Checked == true)
                        {
                            RememberUser(txtUserID.Text.Trim());
                        }
                        Response.Redirect("~/home", true);
                    }
                    else
                    {
                        lblErrMessage.Text = CommonMessages.ERROR_GLOBAL_NO_APPLICATION_ACCESS;
                    }
                }
                else
                {
                    lblErrMessage.Text = CommonMessages.ERROR_GLOBAL_ACCOUNT_NOT_FOUND;
                    txtUserID.Focus();
                }
            }
            catch (Exception ex)
            {
                lblErrMessage.Text = (new GlobalErrorLogsBLL()).LogGlobalError(ex, "TMS - LogIn - LogInUser");
            }
        }
コード例 #3
0
        private void LogInUser(string email, Guid identifier)
        {
            try
            {
                GlobalUsersBLL globalUsersBLL    = new GlobalUsersBLL();
                var            globalUserDetails = globalUsersBLL.AuthenticateUserByOpenID(email, identifier);
                if (globalUserDetails != null)
                {
                    int appUserID = globalUsersBLL.GetApplicationUserByUser(globalUserDetails.UserID, ABCLogisticsApp.TMS);

                    if (appUserID > 0)
                    {
                        Session["GlobalUserID"] = globalUserDetails.UserID.ToString();
                        Session["UserName"]     = globalUserDetails.FirstName + " " + globalUserDetails.LastName;
                        Session["FirstName"]    = globalUserDetails.FirstName;
                        Session["LastName"]     = globalUserDetails.LastName;
                        Session["RoleID"]       = globalUserDetails.RoleID.ToString();
                        Session["UserEmail"]    = globalUserDetails.Email;
                        Session["Password"]     = globalUserDetails.Password;
                        Session["AppUserID"]    = appUserID.ToString();
                        Session["GoogleID"]     = identifier;

                        ScriptManager.RegisterClientScriptBlock(this, GetType(), "AuthReturn", "AuthReturn();", true);
                    }
                    else
                    {
                        lblMsg.Text = CommonMessages.ERROR_GLOBAL_NO_APPLICATION_ACCESS;
                    }
                }
                else
                {
                    lblMsg.Text = CommonMessages.ERROR_GLOBAL_ACCOUNT_NOT_FOUND;
                }
            }
            catch (Exception ex)
            {
                lblMsg.Text = (new GlobalErrorLogsBLL()).LogGlobalError(ex, "TMS - GoogleAuth - LogInUser");
            }
        }