public void Create(SignUp signUp)
        {
            if (_memberRepository.GetByEmail(signUp.Email) == null)
            {
                throw new Exception("Member already exists for Email: " + signUp.Email);
            }

            _authenticationRepository.Create(signUp);
        }
Пример #2
0
 public void Post(CreateKey request)
 {
     _authRepo.Create(new AuthenticationInfo
     {
         AppName     = request.App,
         IsActive    = true,
         AccessToken = Guid.NewGuid().ToString("N"),
         DateCreated = DateTime.UtcNow
     }, CancellationToken.None);
 }
Пример #3
0
 public void Post(CreateKey request)
 {
     _authRepo.Create(new AuthenticationInfo
     {
         AppName     = request.App,
         AccessToken = Guid.NewGuid().ToString("N"),
         DateCreated = DateTime.UtcNow,
         DeviceId    = _appHost.SystemId,
         DeviceName  = _appHost.FriendlyName,
         AppVersion  = _appHost.ApplicationVersion
     });
 }
Пример #4
0
 public ActionResult CreateKey([FromQuery, Required] string app)
 {
     _authRepo.Create(new AuthenticationInfo
     {
         AppName     = app,
         AccessToken = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture),
         DateCreated = DateTime.UtcNow,
         DeviceId    = _appHost.SystemId,
         DeviceName  = _appHost.FriendlyName,
         AppVersion  = _appHost.ApplicationVersionString
     });
     return(NoContent());
 }
        public AuthUser Create(AuthUser user, string password)
        {
            if (string.IsNullOrWhiteSpace(password)) // TODO: set proper rules
            {
                throw new Exception("Password is required");
            }

            if (_userRepository.GetById(user.Id) != null)
            {
                throw new Exception("User is already in the system");
            }

            CreatePasswordHash(password, out var passwordHash);

            user.CurrentPassword = passwordHash;

            return(_userRepository.Create(user));
        }
Пример #6
0
        /// <inheritdoc/>
        public bool AuthorizeRequest(Guid userId, string code)
        {
            ExpireRequests();
            AssertActive();

            if (!_currentRequests.TryGetValue(code, out QuickConnectResult result))
            {
                throw new ResourceNotFoundException("Unable to find request");
            }

            if (result.Authenticated)
            {
                throw new InvalidOperationException("Request is already authorized");
            }

            result.Authentication = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);

            // Change the time on the request so it expires one minute into the future. It can't expire immediately as otherwise some clients wouldn't ever see that they have been authenticated.
            var added = result.DateAdded ?? DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(Timeout));

            result.DateAdded = added.Subtract(TimeSpan.FromMinutes(Timeout - 1));

            _authenticationRepository.Create(new AuthenticationInfo
            {
                AppName     = TokenName,
                AccessToken = result.Authentication,
                DateCreated = DateTime.UtcNow,
                DeviceId    = _appHost.SystemId,
                DeviceName  = _appHost.FriendlyName,
                AppVersion  = _appHost.ApplicationVersionString,
                UserId      = userId
            });

            _logger.LogDebug("Authorizing device with code {Code} to login as user {userId}", code, userId);

            return(true);
        }