public LoginResponse(LoginResponseCode code, int restricttime, string reason)
     : base(0x1312, 0)
 {
     base.m_Stream.Write((ushort)code);
     base.m_Stream.Write(restricttime);
     base.m_Stream.WriteASCIIFixed(reason, reason.Length);
 }
示例#2
0
 public LoginResponse(LoginResponseCode code, int restricttime, string reason)
     : base(0x1312, 0)
 {
     base.m_Stream.Write((ushort)code);
     base.m_Stream.Write(restricttime);
     base.m_Stream.WriteASCIIFixed(reason, reason.Length);
 }
示例#3
0
        public void SendLoginResponse(ClientConnectionInfo connection, LoginResponseCode responseCode, string sceneName)
        {
            var loginResponse = new LoginResponse
            {
                ResponseCode = responseCode,
                SceneName    = sceneName,
            };

            DefaultSend(connection, loginResponse.Create(), ChannelID.Handshaking, true);
        }
示例#4
0
        public static string ErrorCodeToString(LoginResponseCode code)
        {
            switch (code)
            {
            case LoginResponseCode.SYSTEM_ERROR:
                return(Resources.Errors.Common_SystemError);

            case LoginResponseCode.USER_NOT_FOUND:
                return(Resources.Errors.Login_UserNotFound);

            case LoginResponseCode.PASSWORD_EXPIRED:
                return(Resources.Errors.Login_PasswordExpired);

            default:
                return(Resources.Errors.Common_UnknownError);
            }
        }
示例#5
0
        public IHttpActionResult Authenticate([FromBody] LoginRequest login)
        {
            LoginRequest loginrequest = new LoginRequest {
            };

            loginrequest.Username = login.Username;
            loginrequest.Password = login.Password;

            HttpResponseMessage responseMsg = new HttpResponseMessage();
            bool isUsernamePasswordValid    = false;

            if (login != null)
            {
                if (loginrequest.Username == "!S3Lvmue1uhjaT4vr#6fyVIiMO1AijD4hKn2gRObRPGzbF4TSe" &&
                    loginrequest.Password == "13NzgZpJT8Unk#q^jz!b9R1Da#h8sit9XgAXsuwEb&Fa&I3L89Rj5^Qp$d^MKVtpHDZ@M6JomuBHsvI2uMWY7GNL@gJ*ATmX1u6MMuF77GvHB9BzD66nJcimn1thhpb$u1$xt256pb&iMTutt#U#d8Q@gR6MwRlx6iD3M*fzZe5WIhy3K@DRMofsD6d#X@MMHOWiv*w2jpdGdSVPoGu2*GOT!E$Mk7S#44eef4xwFBT%VyKo16m6&25rhfP551Oh")
                {
                    isUsernamePasswordValid = true;
                }
                else
                {
                    isUsernamePasswordValid = false;
                }
            }

            // if credentials are valid
            if (isUsernamePasswordValid)
            {
                GeneratedTokenResponse GeneratedTokenResponse = CreateToken(loginrequest.Username);

                //return the token json
                return(Ok(GeneratedTokenResponse));
            }
            else
            {
                LoginResponseCode loginResponse = new LoginResponseCode {
                };

                // if credentials are not valid send unauthorized status code in response
                loginResponse.ResponseMsg.StatusCode = HttpStatusCode.Unauthorized;
                return(Content(loginResponse.ResponseMsg.StatusCode, "Incorrect username or password! Please try again.", Configuration.Formatters.JsonFormatter));
            }
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CurrentSession" /> class.
        /// </summary>
        /// <param name="userUname">The user uname.</param>
        /// <param name="locationId">The location identifier.</param>
        /// <param name="systemId">The system identifier.</param>
        /// <param name="strPassword">The string password.</param>
        public CurrentSession(string userUname, int locationId, int systemId, string strPassword)
        {
            IUser   LoginManager = (IUser)ObjectFactory.CreateInstance("BusinessProcess.Security.BUser, BusinessProcess.Security");
            DataSet ds           = LoginManager.GetUserCredentials(userUname, locationId, systemId);

            this.isValid    = false;
            this.hasPatient = false;
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count == 1)
            {
                Utility theUtil = new Utility();
                if (theUtil.Decrypt(Convert.ToString(ds.Tables[0].Rows[0]["Password"])) != strPassword)
                {
                    _responseCode = LoginResponseCode.PasswordNotMatch;
                }
                else if (ds.Tables[3].Rows[0]["ExpPwdFlag"] != null && Convert.ToInt32(ds.Tables[0].Rows[0]["UserId"]) != 1 && Convert.ToInt32(ds.Tables[3].Rows[0]["ExpPwdFlag"]) == 1)
                {
                    DateTime lastcontDate      = Convert.ToDateTime(ds.Tables[0].Rows[0]["PwdDate"]);
                    TimeSpan t                 = Convert.ToDateTime(ds.Tables[4].Rows[0]["CurrentDate"]) - lastcontDate;
                    double   NrOfDaysdiffernce = t.TotalDays;
                    if (NrOfDaysdiffernce > Convert.ToInt32(ds.Tables[3].Rows[0]["ExpPwdDays"]))
                    {
                        _responseCode = LoginResponseCode.PasswordExpired;
                    }
                    else
                    {
                        _responseCode = LoginResponseCode.Success;
                    }
                }
                else
                {
                    _responseCode = LoginResponseCode.Success;
                    DataTable theDT    = ds.Tables[2];
                    Facility  facility = new Facility()
                    {
                        Currency    = theDT.Rows[0]["Currency"].ToString(),
                        MasterIndex = theDT.Rows[0]["PosID"].ToString(),
                        PaperLess   = Convert.ToBoolean(theDT.Rows[0]["Paperless"]),
                        Id          = Convert.ToInt32(theDT.Rows[0]["FacilityID"]),
                        Name        = Convert.ToString(theDT.Rows[0]["FacilityName"]),
                        GracePeriod = Convert.ToInt32(theDT.Rows[0]["AppGracePeriod"]),
                        BackupDrive = theDT.Rows[0]["BackupDrive"].ToString(),
                        Active      = true,
                        SatelliteId = Convert.ToInt32(theDT.Rows[0]["SatelliteID"]),
                        DeleteFlag  = false,
                        DateFormat  = (theDT.Rows[0]["DateFormat"] == DBNull.Value || theDT.Rows[0]["DateFormat"].ToString() == "") ? "dd-MMM-yyyy" : theDT.Rows[0]["DateFormat"].ToString(),
                        Integrated  = Convert.ToBoolean(theDT.Rows[0]["Integrated"])
                    };
                    facility.Modules = (from row in ds.Tables[3].AsEnumerable()
                                        select new ServiceArea()
                    {
                        Id = Convert.ToInt32(row["ModuleId"]),
                        Name = Convert.ToString(row["ModuleName"]),
                        DisplayName = Convert.ToString(row["DisplayName"]),
                        EnrolFlag = Convert.ToBoolean(row["CanEnroll"]),
                        ModuleFlag = Convert.ToBoolean(row["ModuleFlag"]),
                        Clinical = Convert.ToBoolean(row["CanEnroll"]),
                        //PublishFlag = (Convert.ToString(row["ModuleName"]) == "PM/SCM") ? false : true,
                        PublishFlag = true,
                        DeleteFlag = false,
                        Active = true,
                        BusinessRules = null,
                        Identifiers = null
                    }).OrderBy(m => m.DisplayName).ToList();
                    //Set pmscm to not published so that it does not show on the page  .. NEEDS improvement
                    if (!facility.PaperLess)
                    {
                        facility.Modules.RemoveAll(m => m.Name.ToUpper() == "LABORATORY" || m.Name.ToUpper() == "PHARMACY"
                                                   // ||
                                                   //  m.Name.ToUpper() == "PM/SCM"
                                                   );
                    }
                    this.HasBilling       = facility.Modules.Exists(m => m.Name.ToUpper() == "BILLING");
                    this.HasPMSCM         = facility.Modules.Exists(m => m.Name.ToUpper() == "PM/SCM");               //&& (facility.PaperLess == true);
                    this.HasWardAdmission = facility.Modules.Exists(m => m.Name.ToUpper() == "WARD ADMISSION");
                    this.HasLabModule     = facility.Modules.Exists(m => m.Name.ToUpper() == "LABORATORY") && (facility.PaperLess == true);
                    DataTable dtUser = ds.Tables[0];
                    User      user   = new User()
                    {
                        Id         = Convert.ToInt32(dtUser.Rows[0]["UserId"]),
                        LoginName  = userUname,
                        FirstName  = Convert.ToString(dtUser.Rows[0]["UserFirstName"]),
                        LastName   = Convert.ToString(dtUser.Rows[0]["UserLastName"]),
                        DeleteFlag = false,
                        Active     = true,
                        Employee   = null
                    };
                    if (dtUser.Rows[0]["EmployeeId"] != DBNull.Value && Convert.ToInt32(dtUser.Rows[0]["EmployeeId"]) > 0)
                    {
                        user.Employee = new Employee()
                        {
                            Id            = Convert.ToInt32(dtUser.Rows[0]["EmployeeId"]),
                            Active        = Convert.ToInt32(dtUser.Rows[0]["EmployeeDeleteFlag"]) == 0,
                            Designation   = Convert.ToString(dtUser.Rows[0]["Designation"]),
                            DesignationId = Convert.ToInt32(dtUser.Rows[0]["DesignationID"])
                        };
                    }
                    this.isValid              = true;
                    this.User                 = user;
                    Facility                  = facility;
                    this.UserDetail           = ds;
                    this.UserRights           = ds.Tables[1];
                    CurrentLandScape          = this.GetLandScape();
                    SessionManager.UserId     = user.Id;
                    SessionManager.FacilityId = facility.Id;
                    SessionManager.SystemId   = facility.SystemId;
                }
            }
            else
            {
                _responseCode = LoginResponseCode.InvalidLogin;
                SessionManager.Dispose();
            }
        }
示例#7
0
        /// <summary>
        /// Handles the Click event of the btnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (btnLogin.CommandName == "Setup")
            {
                string theUrl = string.Format("{0}", "./AdminForms/frmAdmin_FacilityList.aspx");

                HttpContext.Current.ApplicationInstance.CompleteRequest();
                Response.Redirect(theUrl, false);
                return;
            }

            if (ValidateLogin() == false)
            {
                Init_Form();
                return;
            }

            // IUser LoginManager;
            string redirectURL = this.RedirectURL;


            try
            {
                //LoginManager = (IUser)ObjectFactory.CreateInstance("BusinessProcess.Security.BUser, BusinessProcess.Security");
                //DataSet theDS = LoginManager.GetUserCredentials(txtuname.Text.Trim(), Convert.ToInt32(ddLocation.SelectedValue), Convert.ToInt32(Session["SystemId"]));
                LoginResponseCode response = CurrentSession.Login(this, txtuname.Text.Trim(), Convert.ToInt32(ddLocation.SelectedValue), Convert.ToInt32(Session["SystemId"]), txtpassword.Text.Trim());
                if (response == LoginResponseCode.Success)
                {
                    DataSet theDS = CurrentSession.Current.UserDetail;
                    Session["AppUserId"]      = Convert.ToString(theDS.Tables[0].Rows[0]["UserId"]);
                    Session["AppUserName"]    = Convert.ToString(theDS.Tables[0].Rows[0]["UserFirstName"]) + " " + Convert.ToString(theDS.Tables[0].Rows[0]["UserLastName"]);
                    Session["EnrollFlag"]     = theDS.Tables[1].Rows[0]["EnrollmentFlag"].ToString();
                    Session["CareEndFlag"]    = theDS.Tables[1].Rows[0]["CareEndFlag"].ToString();
                    Session["IdentifierFlag"] = theDS.Tables[1].Rows[0]["IdentifierFlag"].ToString();
                    Session["UserRight"]      = theDS.Tables[1];
                    DataTable theDT = theDS.Tables[2];
                    Session["AppLocationId"]     = theDT.Rows[0]["FacilityID"].ToString();
                    Session["AppLocation"]       = theDT.Rows[0]["FacilityName"].ToString();
                    Session["AppCountryId"]      = theDT.Rows[0]["CountryID"].ToString();
                    Session["AppPosID"]          = theDT.Rows[0]["PosID"].ToString();
                    Session["AppSatelliteId"]    = theDT.Rows[0]["SatelliteID"].ToString();
                    Session["GracePeriod"]       = theDT.Rows[0]["AppGracePeriod"].ToString();
                    Session["AppDateFormat"]     = theDT.Rows[0]["DateFormat"].ToString();
                    Session["BackupDrive"]       = theDT.Rows[0]["BackupDrive"].ToString();
                    Session["SystemId"]          = theDT.Rows[0]["SystemId"].ToString();
                    Session["AppCurrency"]       = theDT.Rows[0]["Currency"].ToString();
                    Session["AppUserEmployeeId"] = theDS.Tables[0].Rows[0]["EmployeeId"].ToString();

                    //Session["AppSystemId"] = theDT.Rows[0]["SystemId"].ToString();

                    #region "ModuleId"
                    Session["AppModule"] = theDS.Tables[3];
                    DataView theSCMDV = new DataView(theDS.Tables[3]);
                    theSCMDV.RowFilter = "ModuleId=201";
                    if (theSCMDV.Count > 0)
                    {
                        Session["SCMModule"] = theSCMDV[0]["ModuleName"];
                    }

                    DataView theSamePointDispenseDV = new DataView(theDS.Tables[3]);
                    theSamePointDispenseDV.RowFilter = "ModuleId=30";
                    if (theSamePointDispenseDV.Count > 0)
                    {
                        Session["SCMSamePointDispense"] = theSamePointDispenseDV[0]["ModuleName"];
                    }


                    Session["BillingON"]        = theDS.Tables[3].Select("ModuleName = 'Billing'").Length > 0;
                    Session["AdmissionWardsON"] = theDS.Tables[3].Select("ModuleName = 'Ward Admission'").Length > 0;
                    #endregion
                    IQWebUtils theIQUtils = new IQWebUtils();
                    //theIQUtils.CreateSessionObject(Session.SessionID);
                    Session["Paperless"] = theDT.Rows[0]["Paperless"].ToString();
                    Session["Program"]   = "";
                    HttpContext.Current.ApplicationInstance.CompleteRequest();

                    // FormsAuthentication.SetAuthCookie(txtuname.Text.Trim(), false);
                    Response.Redirect(redirectURL, false);
                }
                else if (response == LoginResponseCode.PasswordNotMatch)
                {
                    if ((Request.Browser.Cookies))
                    {
                        HttpCookie theCookie = Request.Cookies[txtuname.Text];
                        if (theCookie == null)
                        {
                            HttpCookie theNCookie = new HttpCookie(txtuname.Text);
                            theNCookie.Value = txtuname.Text + ",1";
                            DateTime theNewDTTime = Convert.ToDateTime(ViewState["theCurrentDate"]).AddMinutes(5);
                            theNCookie.Expires = theNewDTTime;
                            Response.Cookies.Add(theNCookie);
                        }

                        else
                        {
                            string[] theVal = (theCookie.Value.ToString()).Split(',');
                            if (Convert.ToInt32(theVal[1]) >= 3 && theCookie.Name == txtuname.Text)
                            {
                                MsgBuilder theBuilder = new MsgBuilder();
                                theBuilder.DataElements["MessageText"] = "User Account Locked. Try again after 5 Mins.";
                                IQCareMsgBox.Show("#C1", theBuilder, this);
                                return;
                            }
                            else
                            {
                                theVal[1]       = (Convert.ToInt32(theVal[1]) + 1).ToString();
                                theCookie.Value = txtuname.Text + "," + theVal[1];
                                DateTime theAddNewDTTime = Convert.ToDateTime(ViewState["theCurrentDate"]).AddMinutes(5);
                                theCookie.Expires = theAddNewDTTime;
                                Response.Cookies.Add(theCookie);
                            }
                        }
                    }
                    IQCareMsgBox.Show("PasswordNotMatch", this);
                    Init_Form();
                    return;
                }
                else if (response == LoginResponseCode.PasswordExpired)
                {
                    string theUrl    = string.Format("{0}", "./AdminForms/frmAdmin_ChangePassword.aspx");
                    string msgString = "Your Password has expired. Please Change it now.\\n";
                    string script    = "<script language = 'javascript' defer ='defer' id = 'changePwdfunction2'>\n";
                    script += "alert('" + msgString + "');\n";
                    string url = Request.RawUrl.ToString();
                    Application["PrvFrm"]      = url;
                    Session["MandatoryChange"] = "1";
                    script += "window.location.href='" + theUrl + "'\n";
                    script += "</script>\n";
                    ClientScript.RegisterStartupScript(this.GetType(), "changePwdfunction2", script);
                }
                else if (response == LoginResponseCode.InvalidLogin)
                {
                    IQCareMsgBox.Show("InvalidLogin", this);
                    Init_Form();
                    return;
                }
            }
            catch (Exception err)
            {
                MsgBuilder theBuilder = new MsgBuilder();
                theBuilder.DataElements["MessageText"] = err.Message.ToString();
                IQCareMsgBox.Show("#C1", theBuilder, this);
            }
            finally
            {
                //LoginManager = null;
            }
        }
 public LoginResponse(LoginResponseCode code)
     : base(0x1312, 8)
 {
     base.m_Stream.Write((ushort)code);
 }
示例#9
0
 public LoginResponse(LoginResponseCode code)
     : base(0x1312, 8)
 {
     base.m_Stream.Write((ushort)code);
 }
示例#10
0
 public LoginResponse(LoginResponseCode code)
 {
     this.Code = code;
 }
示例#11
0
 /// <summary>
 /// Creates a login response payload with the specified <see cref="LoginResponseCode"/>.
 /// </summary>
 /// <param name="code">Response code indicating the result of a <see cref="LoginRequest"/>.</param>
 public LoginResponse(LoginResponseCode code)
 {
     Code = code;
 }