aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Local/LocalUserServices.cs
blob: ac680ca2eb62c96ad8af5acca9a334e38e6f237e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Types;
using OpenSim.Framework.UserManagement;

namespace OpenSim.Region.Communications.Local
{
    public class LocalUserServices : UserManagerBase
    {
        private readonly NetworkServersInfo m_serversInfo;
        private readonly uint m_defaultHomeX;
        private readonly uint m_defaultHomeY;
        private IInventoryServices m_inventoryService;


        public LocalUserServices(NetworkServersInfo serversInfo, uint defaultHomeLocX, uint defaultHomeLocY, IInventoryServices inventoryService)
        {
            m_serversInfo = serversInfo;

            m_defaultHomeX = defaultHomeLocX;
            m_defaultHomeY = defaultHomeLocY;

            m_inventoryService = inventoryService;
            
        }

        public override UserProfileData SetupMasterUser(string firstName, string lastName)
        {
            return SetupMasterUser(firstName, lastName, "");
        }

        public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
        {
            UserProfileData profile = GetUserProfile(firstName, lastName);
            if (profile != null)
            {
                return profile;
            }

            Console.WriteLine("Unknown Master User. Sandbox Mode: Creating Account");
            AddUserProfile(firstName, lastName, password, m_defaultHomeX, m_defaultHomeY);

            profile = GetUserProfile(firstName, lastName);

            if (profile == null)
            {
                Console.WriteLine("Unknown Master User after creation attempt. No clue what to do here.");
            }
            else
            {
                m_inventoryService.CreateNewUserInventory(profile.UUID);
            }

            return profile;
        }
    }
}