Пример #1
0
        public async Task <BasicUser> CreateUser(NewUser user, Guid campusId)
        {
            // get campus and lead for user
            var campus = await _graphGroupService.GetGroupById(campusId);

            var graphUser    = CreateGraphUser(user, Campus.FromMccGroup(campus));
            var userPassword = graphUser.PasswordProfile.Password.ToSecureString();

            graphUser = await _graphService.Client.Users.Request().AddAsync(graphUser);

            // add user to the corresponding groups
            await _graphGroupService.AddUserToGroup(graphUser, _authorizationConfiguration.CommunityGroupId);

            await _graphGroupService.AddUserToGroup(graphUser, campusId);

            // add licence
            await AssignLicense(graphUser);

            // add new user as additional direct to lead
            var lead = await GetLeadForCampus(campus.Id);

            await AssignManager(graphUser, lead.Id);

            // Send welcome mail
            await SendNewUserWelcomeMail(graphUser, user, lead, userPassword);

            return(BasicUser.FromGraphUser(graphUser));
        }
Пример #2
0
        public async Task <BasicUser> GetBasicUserById(Guid userId, UserScope scope)
        {
            var user = await GetGraphUserById(userId);

            if (scope == UserScope.Basic)
            {
                return(BasicUser.FromGraphUser(user));
            }

            return(await AddFullScope(user));
        }