Beispiel #1
0
        private User RegisterUser(ISystemUnitOfWork unitOfWork, ExtAccount extAccount)
        {
            User user = _securityUserService.RegisterUser(unitOfWork, extAccount.ToUser());

            if (user == null) return null;

            extAccount.User = user;
            _AttachImage(unitOfWork, user, extAccount.ProfilePicture);
            _extAccountService.Create(unitOfWork, extAccount);

            return user;
        }
Beispiel #2
0
        private ExtAccount AddAccount(IUnitOfWork unitOfWork, ExtAccount newAccount)
        {
            var linkedAccounts = _extAccountService.GetLinked(unitOfWork, Ambient.AppContext.SecurityUser.ID);
            if (!linkedAccounts.Any(x => x.Type == newAccount.Type && x.ExternalId == newAccount.ExternalId))
            {
                newAccount.UserID = Ambient.AppContext.SecurityUser.ID;
                _extAccountService.Create(unitOfWork, newAccount);
            }

            return newAccount;
        }
Beispiel #3
0
        private User Authorize(ISystemUnitOfWork unitOfWork, ExtAccount extAccount)
        {
            User user = _extAccountService.GetAll(unitOfWork)
                     .Where(x => x.Type == extAccount.Type && x.ExternalId == extAccount.ExternalId)
                     .Select(x => x.User).FirstOrDefault();

            if (user == null)
            {
                var securityUser = _securityUserService.GetSecurityUser(extAccount.Email);

                if (securityUser != null)
                {
                    AddAccount(unitOfWork, extAccount);
                    user = new User { Login = securityUser.Login };
                }
                else
                {
                    user = RegisterUser(unitOfWork, extAccount);
                }
            }

            return user;

        }