Exemple #1
0
 protected Connector.QueryResult AuthenByDB(string storeName, Connector.QueryParameter loginParameter)
 {
     Connector.IDatabaseConnector dbConnector = new Connector.DatabaseConnectorClass();
     Connector.QueryResult        loginResult = dbConnector.ExecuteStoredProcedure(storeName, loginParameter);
     if (loginResult.Success)
     {
         if (loginResult.DataTable != null && loginResult.DataTable.Rows.Count > 0)
         {
             foreach (DataColumn dc in loginResult.DataTable.Columns)
             {
                 Session["DVS_" + dc.ColumnName] = loginResult.DataTable.Rows[0][dc.ColumnName];
             }
             loginResult = GetSystemPermission(Session["DVS_USER_ID"].ToString());
             Session.Remove("DVS_IS_GUEST");
         }
         else
         {
             throw new Exception(loginResult.Message);
         }
     }
     else
     {
         throw new Exception(loginResult.Message);
     }
     return(loginResult);
 }
Exemple #2
0
    public static void ApplicationLogout(HttpSessionState Session, HttpResponse Response = null)
    {
        Connector.IDatabaseConnector dbConnector     = new Connector.DatabaseConnectorClass();
        Connector.QueryParameter     logoutParameter = new Connector.QueryParameter();
        Connector.QueryResult        logoutResult    = new Connector.QueryResult();

        if (Session != null && Session["DVS_USER_ID"] != null)
        {
            if (Session["AUTHEN_TOKEN"] != null)
            {
                AMSDuplicateAuthenCore.ClearToken(Session["DVS_USER_ID"].ToString(), Session["AUTHEN_TOKEN"].ToString());
            }

            logoutParameter.Add("USER_ID", Session["DVS_USER_ID"]);
            logoutResult         = dbConnector.ExecuteStoredProcedure("SYS_I_LOGOUT", logoutParameter);
            logoutResult.Success = true;
            logoutResult.Message = string.Empty;
            logoutResult.RemoveOutputParam("error");
            Session.Abandon();
        }

        if (Response != null)
        {
            HttpCookie authenTokenCookie = new HttpCookie("AUTHEN_TOKEN");
            authenTokenCookie.Value = "";
            Response.Cookies.Add(authenTokenCookie);

            Response.ClearContent();
            Response.ContentType = "application/json";
            Response.Write(logoutResult.ToJson());
        }
    }
Exemple #3
0
    protected Connector.QueryResult GetSystemPermission(string userid)
    {
        if (userid == "999999999")
        {
            return(GetPrivatePermission());
        }
        Connector.IDatabaseConnector dbConnector      = new Connector.DatabaseConnectorClass();
        Connector.QueryResult        permissionResult = null;
        permissionResult = dbConnector.ExecuteStoredProcedure("APP_Q_CONFIG", new Connector.QueryParameter(new Dictionary <string, object>()
        {
            { "USER_ID", userid }
        }));
        Dictionary <string, object> session = new Dictionary <string, object>();

        foreach (string sKey in Session.Keys)
        {
            if (!sKey.StartsWith("DVS_"))
            {
                continue;
            }
            session.Add(sKey.Replace("DVS_", ""), Session[sKey]);
        }
        permissionResult.AddOutputParam("session", session);
        return(permissionResult);
    }
Exemple #4
0
    protected bool PageSelector(string request, out string wgNamespace, out Dictionary <string, object> wgParameters)
    {
        wgNamespace  = string.Empty;
        wgParameters = new Dictionary <string, object>();

        switch (request)
        {
        case "portal":
            wgNamespace = "viewer/Portal/Portal";
            if (Session != null && Session["DVS_USER_ID"] != null)
            {
                if (!checkAuthentication())
                {
                    return(false);
                }

                if (AMSCore.WebConfigReadKey("AUTHENTICATION_TYPE") == "1")
                {
                    wgParameters = new Dictionary <string, object>()
                    {
                        { "permission", GetSystemPermission(Session["DVS_USER_ID"].ToString()).ToDictionary() }
                    };
                }
                else if (AMSCore.WebConfigReadKey("AUTHENTICATION_TYPE") == "2")
                {
                    wgParameters = new Dictionary <string, object>()
                    {
                        { "permission", AuthenByAD(Session["DVS_USER_ID"].ToString()).ToDictionary() }
                    };
                }
                else if (AMSCore.WebConfigReadKey("AUTHENTICATION_TYPE") == "3")
                {
                }
            }
            else if (AMSCore.WebConfigReadKey("GUEST_ENABLED") != null && AMSCore.WebConfigReadKey("GUEST_ENABLED").Equals("1"))
            {
                Session["DVS_IS_GUEST"] = true;
                Session["DVS_USER_ID"]  = AMSCore.WebConfigReadKey("GUEST_USER_ID");
                wgParameters            = new Dictionary <string, object>()
                {
                    { "permission", GetSystemPermission(Session["DVS_USER_ID"].ToString()).ToDictionary() }
                };
            }
            break;

        case "logout":
        {
            ApplicationLogout(Session, Response);
            if (Request.HttpMethod != "POST")
            {
                Response.Redirect("~/", true);
            }
            return(false);
        }

        case "system":
            if (Request.HttpMethod == "POST")
            {
                Response.ClearContent();

                Connector.QueryParameter reqParameter = new Connector.QueryParameter(Request);
                if (reqParameter["SYS_ID"].Equals("-1"))
                {
                    Session.Remove("DVS_SYSTEM_ID");
                }
                else
                {
                    Session["DVS_SYSTEM_ID"] = reqParameter["SYS_ID"];
                }
                Response.ContentType = "application/json";
                Response.Write(new Connector.QueryResult().ToJson());

                return(false);
            }
            else if (!checkAuthentication())
            {
                return(false);
            }

            break;

        case "forgetPassword":
        {
            wgNamespace  = "viewer/ForgetPassword/ForgetPassword";
            wgParameters = new Dictionary <string, object>()
            {
                { "token", Request.Params["token"] },
                { "userid", Request.Params["userid"] },
                { "forgetByEmail", true }
            };
            break;
        }

        case "APP_Q_LOGIN":
        {
            Response.ClearContent();

            ApplicationLogin("APP_Q_LOGIN");
            return(false);
        }

        case "UM_Q_VERIFY_USER":
        case "UM_U_PWD":
        case "UM_U_RESET_PWD":
        case "UM_Q_MAIL_TOKEN":
        {
            Response.ClearContent();

            string storeName = request;

            Connector.IDatabaseConnector dbConnector  = new Connector.DatabaseConnectorClass();
            Connector.QueryParameter     reqParameter = new Connector.QueryParameter(Request);

            Connector.QueryResult logoutResult = dbConnector.ExecuteStoredProcedure(storeName, reqParameter);

            Response.ContentType = "application/json";
            Response.Write(logoutResult.ToJson());
            return(false);
        }

        default:
            break;
        }

        return(true);
    }