Exemplo n.º 1
0
        async Task IGangAuthenticationService
        .RequestLinkAsync(string email, object data)
        {
            _logger.LogDebug($"Requesting link for {email}");

            var user = await _users.TryGetByEmailAddressAsync(email);

            if (user == null)
            {
                user = new GangUserData(
                    $"{Guid.NewGuid():N}",
                    null, email
                    );
            }

            var linkCode = new GangUserLinkCode(
                _crypto.GetRandom(_settings.LinkParts ?? DEFAULT_LINK_PARTS),
                DateTimeOffset.Now.AddMinutes(_settings.LinkExpiryMinutes ?? DEFAULT_LINK_EXPIRY_MINUTES)
                );

            user = user.SetLinkCode(linkCode);

            await _users.SetAsync(user);

            _manager.RaiseEvent(
                user.GetLink(linkCode, data)
                );
        }