示例#1
0
        public void EnterPrivateSession <S>(WSDataContext db, ClientFunctions CFunc, WSTableSource SessionSrc, WSUserToken _user, string _1MinTicket, ref WSStatus statusLines, bool renew = false) where S : WSDynamicEntity
        {
            try
            {
                if (db != null)
                {
                    if (ExitPrivateSession <S>(db, CFunc, SessionSrc, ref statusLines) && renew && _user.IsValid && ValidateOneMinTicket(_1MinTicket))
                    {
                        try
                        {
                            AuthToken.User = _user;

                            S _session = (S)Activator.CreateInstance(typeof(S), new object[] { });

                            setSession(DateTime.Now, SessionID, AuthToken.User.id, ref _session);

                            db.GetTable <S>().InsertOnSubmit(_session);

                            db.SubmitChanges();

                            Func <S, bool> func = s => s.readPropertyValue(WSConstants.PARAMS.SESSIONID.NAME, "").ToString().ToLower().Equals(SessionID.ToLower());

                            Session = db.GetTable <S>().FirstOrDefault(func);
                        }
                        catch (Exception e) { CFunc.RegError(GetType(), e, ref statusLines); Session = null; }
                    }
                }

                if (Session != null)
                {
                    setAuthToken(Session, ref _AuthToken);
                }
            }
            catch (Exception e) { CFunc.RegError(GetType(), e, ref statusLines); }
        }
示例#2
0
        public WSSecurity(WSDynamicEntity _Session, string _SessionID, MetaFunctions _CFunc)
        {
            Session   = _Session;
            SessionID = _SessionID;
            CFunc     = _CFunc;
            try
            {
                AuthToken.User = new WSUserToken();
                if (_Session != null)
                {
                    SessionID = _Session.readPropertyValue("SessionID").ToString();
                    object userObj = _Session.readPropertyValue("User");
                    if (userObj != null)
                    {
                        WSDynamicEntity user = (WSDynamicEntity)userObj;

                        object id        = user.readPropertyValue("UserID");
                        object email     = user.readPropertyValue("Email");
                        object login     = user.readPropertyValue("Login");
                        object firstname = user.readPropertyValue("FirstName");
                        object lastname  = user.readPropertyValue("LastName");
                        object role      = user.readPropertyValue("RoleID");
                        object isactive  = user.readPropertyValue("IsActive");
                        object password  = user.readPropertyValue("Password");

                        AuthToken.User = new WSUserToken()
                        {
                            id        = int.Parse(id.ToString()),
                            email     = email == null ? "" : email.ToString(),
                            login     = login == null ? "" : login.ToString(),
                            firstname = firstname == null ? "" : firstname.ToString(),
                            lastname  = lastname == null ? "" : lastname.ToString(),
                            role      = role == null ? (byte)0 : byte.Parse(role.ToString()),
                            isactive  = isactive == null ? false : isactive.ToString().IsTrue()
                        };
                        WSCurrentUser = new WSCurrentUser(user);
                        UPass         = password == null ? "" : password.ToString();
                    }
                }
            }
            catch (Exception e) { CFunc.RegError(GetType(), e, ref status); }
        }
 public WSSecurityDefault(WSDynamicEntity _Session, string _SessionID, MetaFunctions _CFunc) : base(_Session, _SessionID, _CFunc)
 {
 }
示例#4
0
 public WSCurrentUser(WSDynamicEntity _entity)
 {
     entity = _entity;
 }