Exemplo n.º 1
0
        private UserSession AnonymousLogin(string name, byte accessLevel, OSDMap extraData, string identifier, string type, string credential)
        {
            User user;

            if (!m_userClient.TryAuthorizeIdentity(identifier, type, credential, out user))
            {
                // We don't have an e-mail address for this person so just create a random string for the e-mail
                string email = "INVALID " + UUID.Random().ToString();

                // Create a new user and identity
                m_userClient.CreateUser(name, email, accessLevel, extraData, out user);
                m_userClient.CreateIdentity(new Identity {
                    UserID = user.ID, Enabled = true, Credential = credential, Identifier = identifier, Type = type
                });
            }

            // Create a session for this user
            UserSession session = new UserSession(user);

            session.SessionID       = UUID.Random();
            session.SecureSessionID = UUID.Random();
            session.SetField("CircuitCode", OSD.FromInteger(m_circuitCodeGenerator.Next()));
            user.LastLogin = DateTime.UtcNow;

            // Store the session in the user service
            m_userClient.AddSession(session);

            return(session);
        }