Esempio n. 1
0
        // deauthenticates the user given by the input session
        public void Deauthenticate(ref UserSession session)
        {
            // gets the sessions authenticated id (possibly null)
            var authenticatedId = session?.Identity().AuthenticatedId;
            if (authenticatedId == null) return;

            // deauthenticates the current user
            var userId = new UserIdentity(authenticatedId.GetValueOrDefault(), "");
            session = new UserSession(userId, false);
        }
Esempio n. 2
0
        // confirms write access to data related to the user id contained in the session
        public bool ConfirmWriteAccess(UserSession session)
        {
            if (session == null || session.Authenticated() == false) return false;

            // returns false if user could not be authenticated based on the input   
            using (var db = new SmartPoolContext())
            {
                // queries the database for users matching input session
                var userQuery = from users in db.UserSet
                                where
                                    users.Id == session.Identity().AuthenticatedId &&
                                    users.Password == session.Identity().Password
                                select users.Id;

                // returns true if the input was matched by the query
                return userQuery.Any();
            }
        }
Esempio n. 3
0
 // confirms read access to data related to the user id contained in the session
 public bool ConfirmReadAccess(UserSession session)
 {
     return session.Authenticated();
 }
Esempio n. 4
0
 // nullifies the input session
 public void Nullify(ref UserSession session)
 {
     session = null;
 }