public AuthResult Login(string userName, string password, bool isPersistent, string customData)
 {
     AuthResult result;
     if (_authenticationProvider.VerifyUser(userName, password, out result))
     {
         SessionStorage sessionStorage = new SessionStorage(userName);
         Users users = GetUser(userName);
         //IPrincipal principal = new GenericPrincipal(new GenericIdentity(userName, "Forms"), DefaultRoles.ToArray<string>());
         HttpContext.Current.User = new GenericPrincipal(new GenericIdentity(userName, "Forms"),
                                                         users.Group.Select(x => x.Name).ToArray());
         Dictionary<string, string> values = new Dictionary<string, string>();
         //values.Add("UserId", users.Id.ToString());
         //HttpContext.Current.Profile.SetPropertyValue("Id",users.Id);
         sessionStorage.UserId = users.Id;
         FormsAuthentication.SetAuthCookie(userName, isPersistent);
         sessionStorage.DataPermission = GetDataPermissions(userName);
         sessionStorage.UserSpecificValues = values;
     }
     return result;
 }
Esempio n. 2
0
        private PermissionLog CreateLog(string message,short operation,int UserId)
        {
            SessionStorage sessionStorage = new SessionStorage(HttpContext.Current.User.Identity.Name);
            PermissionLog log=new PermissionLog();
            log.CreatedBy = sessionStorage.UserId;
            log.CreatedDate = DateTime.Now;
            log.Message = message;
            log.Operation = operation;
            log.UserId = UserId;
            return log;

        }