예제 #1
0
        public Operation <User> LoginUser(string UserName, string Password)
        {
            Operation <User> op_ = new Operation <User>();

            try
            {
                //string openPassword = DataIO.Cryptor.Decrypt(Password);
                string   openPassword = new RijndaelCrypt("D8903F7F075E4877A6C5F62EC68A2018").Decrypt(Password);
                BaseUser baseUser     = connection.Query <BaseUser>(" select * From [BaseUser] where UserName = @UserName AND PassHash = @PassHash ", new { UserName = UserName, PassHash = Password }).FirstOrDefault();
                if (baseUser == null)
                {
                    op_.Fail = "istifadəçi adı və ya şifrə yanlışdır";
                    return(op_);
                }
                if (baseUser.IsActive == false)
                {
                    op_.Fail = "istifadəçi adı passivdir";
                    return(op_);
                }
                LoginSession loginSession = connection.Query <LoginSession>("EXECUTE [dbo].[SP_GetSessionGuid] " + baseUser.Id.ToString()).FirstOrDefault();
                if (loginSession == null)
                {
                    op_.Fail = "Unable to get login session";
                    return(op_);
                }

                List <PermissionDetail> permissionDetails = GetPermissionDetailsByUserId(baseUser.Id).Value;
                if (permissionDetails == null)
                {
                    op_.Fail = "Unable to get login permissions";
                    return(op_);
                }

                User user = baseUser.GetEligibleOjbect <User>();
                user.PermissionDetails = permissionDetails;
                user.LoginSession      = loginSession;
                op_.Value      = user;
                op_.Successful = true;
            }
            catch (Exception ex)
            {
                op_.Fail = ex.Message;
            }

            return(op_);
        }
예제 #2
0
        public Operation <User> GetUserById(int Id)
        {
            Operation <User> op_ = new Operation <User>();

            try
            {
                BaseUser baseUser = connection.Get <BaseUser>(Id);
                List <PermissionDetail> permissionDetails = GetPermissionDetailsByUserId(Id).Value;
                User user = baseUser.GetEligibleOjbect <User>();
                user.PermissionDetails = permissionDetails;
                user.LoginSession      = null;
                op_.Value      = user;
                op_.Successful = true;
            }
            catch (Exception ex)
            {
                op_.Fail = ex.Message;
            }

            return(op_);
        }