コード例 #1
0
ファイル: AppAuthController.cs プロジェクト: Shikha199/NeoGo
        public HttpResponseMessage AppUserLogin(AppUserModel objUser)
        {
            try
            {
                HttpResponseMessage RetResponse = new HttpResponseMessage();
                string var_LoginD    = objUser.LoginID;
                string var_PasswordD = objUser.Password;
                string var_ErrorMsg  = "";

                if (CodeAssistance.F_ValidateStrLen(var_LoginD, 25))
                {
                    var_ErrorMsg = var_ErrorMsg + "invalid string length for LoginID";
                }
                if (CodeAssistance.F_ValidateStrLen(var_PasswordD, 25))
                {
                    var_ErrorMsg = var_ErrorMsg + "invalid string length for Password";
                }
                var_LoginD    = CodeAssistance.F_ValidateString("ALL", var_LoginD, ".@");
                var_PasswordD = CodeAssistance.F_ValidateString("RemoveSingleQuote", var_PasswordD, "");
                var_PasswordD = CodeAssistance.F_ValidateString("RemoveNextLine", var_PasswordD, ".@");
                var_PasswordD = CodeAssistance.F_ValidateString("RemoveSpace", var_PasswordD, "");;
                var_PasswordD = CodeAssistance.F_ValidateString("RemoveSingleQuote", var_PasswordD, "");

                if (var_LoginD.Length == 0)
                {
                    var_ErrorMsg = var_ErrorMsg + "LoginID cannot be blank";
                }
                if (var_PasswordD.Length == 0)
                {
                    var_ErrorMsg = var_ErrorMsg + "Password cannot be blank";
                }

                if (var_ErrorMsg.Length == 0)
                {
                    if (MEF.Security_ValidateUser("APPUSER", var_LoginD, var_PasswordD))
                    {
                        //Create User Object

                        objUser     = AppData.Get_User_Data_By_LoginID(var_LoginD);
                        RetResponse = Request.CreateResponse(HttpStatusCode.OK, (new JsonRetMessage(false, true, "Login Successfully", objUser)));
                    }
                    else
                    {
                        RetResponse = Request.CreateResponse(HttpStatusCode.OK, (new JsonRetMessage(false, true, "invalid userid or password", objUser)));
                    }
                }
                else
                {
                    RetResponse = Request.CreateResponse(HttpStatusCode.OK, (new JsonRetMessage(false, true, var_ErrorMsg, null)));
                }
                return(RetResponse);
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, (new JsonRetMessage(true, false, "internal server error " + Environment.NewLine + ex.Message, null))));
            }
        }