public async Task Callback(SignInCallback callback)
 {
     using (var request = new HttpRequestMessage(HttpMethod.Post, $"/api/v1/contacts/callback"))
     {
         await PostPutRequest(request, callback);
     }
 }
        public async Task <ActionResult> Callback([FromBody] SignInCallback callback)
        {
            _logger.LogInformation($"Received callback from ASLogin: Sub: {callback.Sub} SourceId: {callback.SourceId}");
            await _mediator.Send(new UpdateSignInIdRequest(Guid.Parse(callback.Sub), Guid.Parse(callback.SourceId)));

            return(Ok());
        }
Beispiel #3
0
 /// <summary>
 /// Sends a request to server, to log in as a guest
 /// </summary>
 public void SignInAsGuest(SignInCallback callback, IClientSocket connection)
 {
     SignIn(new Dictionary <string, string>()
     {
         { "guest", string.Empty }
     }, callback, connection);
 }
Beispiel #4
0
        /// <summary>
        /// Sends a login request, using given token
        /// </summary>
        public void SignInWithToken(string token, SignInCallback callback, IClientSocket connection)
        {
            var credentials = new MstProperties();

            credentials.Add(MstDictKeys.USER_AUTH_TOKEN, token);

            SignIn(credentials, callback, connection);
        }
Beispiel #5
0
        /// <summary>
        /// Sends a login request, using given token
        /// </summary>
        public void SignIn(string token, SignInCallback callback, IClientSocket connection)
        {
            var credentials = new MstProperties();

            credentials.Add("token", token);

            SignIn(credentials, callback, connection);
        }
Beispiel #6
0
        /// <summary>
        /// Sends a login request, using given credentials
        /// </summary>
        public void SignInWithEmail(string email, SignInCallback callback, IClientSocket connection)
        {
            var credentials = new MstProperties();

            credentials.Add(MstDictKeys.USER_EMAIL, email);

            SignIn(credentials, callback, connection);
        }
Beispiel #7
0
        /// <summary>
        /// Sends a request to server, to log in as a guest
        /// </summary>
        public void SignInAsGuest(SignInCallback callback, IClientSocket connection)
        {
            var credentials = new MstProperties();

            credentials.Add("guest", string.Empty);

            SignIn(credentials, callback, connection);
        }
Beispiel #8
0
        /// <summary>
        /// Sends a login request, using given credentials
        /// </summary>
        public void SignInWithPhoneNumber(string phoneNumber, SignInCallback callback, IClientSocket connection)
        {
            var credentials = new MstProperties();

            credentials.Add(MstDictKeys.USER_PHONE_NUMBER, phoneNumber);

            SignIn(credentials, callback, connection);
        }
Beispiel #9
0
 /// <summary>
 /// Sends a login request, using given credentials
 /// </summary>
 public void SignIn(string username, string password, SignInCallback callback, IClientSocket connection)
 {
     SignIn(new Dictionary <string, string>
     {
         { "username", username },
         { "password", password }
     }, callback, connection);
 }
Beispiel #10
0
        /// <summary>
        /// Sends a request to server, to log in as a guest
        /// </summary>
        /// <param name="callback"></param>
        public void SignInAsGuest(SignInCallback callback)
        {
            Logs.Debug("Signing in as Guest...");

            SignIn(new Dictionary <string, string>()
            {
                { "guest", string.Empty }
            }, callback, Connection);
        }
Beispiel #11
0
        /// <summary>
        /// Sends a login request, using given credentials
        /// </summary>
        public void SignInWithLoginAndPassword(string username, string password, SignInCallback callback, IClientSocket connection)
        {
            var credentials = new MstProperties();

            credentials.Add(MstDictKeys.USER_NAME, username);
            credentials.Add(MstDictKeys.USER_PASSWORD, password);

            SignIn(credentials, callback, connection);
        }
Beispiel #12
0
        /// <summary>
        /// Sends a login request, using given credentials
        /// </summary>
        public void SignIn(string username, string password, SignInCallback callback, IClientSocket connection)
        {
            var credentials = new MstProperties();

            credentials.Add(MstDictKeys.userName, username);
            credentials.Add(MstDictKeys.userPassword, password);

            SignIn(credentials, callback, connection);
        }
Beispiel #13
0
        /// <summary>
        /// Sends a request to server, to log in with auth token
        /// </summary>
        /// <param name="callback"></param>
        public void SignInWithToken(SignInCallback callback)
        {
            if (!HasAuthToken())
            {
                throw new Exception("You have no auth token!");
            }

            SignIn(PlayerPrefs.GetString(AuthTokenKey()), callback);
        }
Beispiel #14
0
        /// <summary>
        /// Sends a request to server, to log in with auth token
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="connection"></param>
        public void SignInWithToken(SignInCallback callback, IClientSocket connection)
        {
            if (!HasAuthToken())
            {
                throw new Exception("You have no auth token!");
            }

            SignInWithToken(PlayerPrefs.GetString(MstDictKeys.USER_AUTH_TOKEN), callback, connection);
        }
        /// <summary>
        /// Sends a login request, using given credentials
        /// </summary>
        public void SignIn(string username, string password, SignInCallback callback, IClientSocket connection)
        {
            var credentials = new DictionaryOptions();

            credentials.Add("username", username);
            credentials.Add("password", password);

            SignIn(credentials, callback, connection);
        }
Beispiel #16
0
        /// <summary>
        /// Sends a generic login request
        /// </summary>
        public void SignIn(MstProperties data, SignInCallback callback, IClientSocket connection)
        {
            Logs.Debug("Signing in...");

            if (!connection.IsConnected)
            {
                callback.Invoke(null, "Not connected to server");
                return;
            }

            IsNowSigningIn = true;

            // We first need to get an aes key
            // so that we can encrypt our login data
            Mst.Security.GetAesKey(aesKey =>
            {
                if (aesKey == null)
                {
                    IsNowSigningIn = false;
                    callback.Invoke(null, "Failed to log in due to security issues");
                    return;
                }

                var encryptedData = Mst.Security.EncryptAES(data.ToBytes(), aesKey);

                connection.SendMessage((short)MstMessageCodes.SignInRequest, encryptedData, (status, response) =>
                {
                    IsNowSigningIn = false;

                    if (status != ResponseStatus.Success)
                    {
                        ClearAuthToken();

                        callback.Invoke(null, response.AsString("Unknown error"));
                        return;
                    }

                    AccountInfo = response.Deserialize(new AccountInfoPacket());

                    IsSignedIn = true;

                    if (RememberMe)
                    {
                        SaveAuthToken(AccountInfo.Token);
                    }
                    else
                    {
                        ClearAuthToken();
                    }

                    callback.Invoke(AccountInfo, null);

                    OnSignedInEvent?.Invoke();
                });
            }, connection);
        }
Beispiel #17
0
        /// <summary>
        /// Sends a request to server, to log in as a guest
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="connection"></param>
        public void SignInAsGuest(SignInCallback callback, IClientSocket connection)
        {
            var credentials = new MstProperties();

            credentials.Add(MstDictKeys.USER_IS_GUEST);
            credentials.Add(MstDictKeys.USER_DEVICE_NAME, SystemInfo.deviceName);
            credentials.Add(MstDictKeys.USER_DEVICE_ID, SystemInfo.deviceUniqueIdentifier);

            SignIn(credentials, callback, connection);
        }
        public Task <SignInResult> SignInAsync(Credentials credentials, bool lockoutOnFailure = true)
        {
            var loginDto = LoginDto.FromCredentials(credentials, lockoutOnFailure, DateTime.UtcNow + TimeSpan.FromSeconds(loginExpirationSeconds));
            var callback = new SignInCallback <TUser>(loginDto, this);

            var protector          = _dataProtectionProvider.CreateProtector("login");
            var encodedCredentials = protector.Protect(JsonSerializer.Serialize(loginDto));

            _jSRuntime.InvokeVoidAsync("shadyAuthHelpers.login", encodedCredentials, DotNetObjectReference.Create(callback));

            return(callback.ResultSource.Task);
        }
Beispiel #19
0
        /// <summary>
        /// Sends a request to server, to log in as a guest
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="connection"></param>
        public void SignInAsGuest(SignInCallback callback, IClientSocket connection)
        {
            if (HasAuthToken())
            {
                SignInWithToken(callback, connection);
            }
            else
            {
                var credentials = new MstProperties();
                credentials.Add(MstDictKeys.USER_IS_GUEST);

                SignIn(credentials, callback, connection);
            }
        }
Beispiel #20
0
 /// <summary>
 /// Sends a generic login request
 /// </summary>
 /// <param name="data"></param>
 /// <param name="callback"></param>
 public void SignIn(Dictionary <string, string> data, SignInCallback callback)
 {
     SignIn(data, callback, Connection);
 }
Beispiel #21
0
        /// <summary>
        /// Sends a generic login request
        /// </summary>
        public void SignIn(MstProperties data, SignInCallback callback, IClientSocket connection)
        {
            Logs.Debug("Signing in...");

            if (!connection.IsConnected)
            {
                callback.Invoke(null, "Not connected to server");
                return;
            }

            IsNowSigningIn = true;

            // We first need to get an aes key
            // so that we can encrypt our login data
            Mst.Security.GetAesKey(aesKey =>
            {
                if (aesKey == null)
                {
                    IsNowSigningIn = false;
                    callback.Invoke(null, "Failed to log in due to security issues");
                    return;
                }

                var encryptedData = Mst.Security.EncryptAES(data.ToBytes(), aesKey);

                connection.SendMessage((short)MstMessageCodes.SignIn, encryptedData, (status, response) =>
                {
                    IsNowSigningIn = false;

                    if (status != ResponseStatus.Success)
                    {
                        ClearAuthToken();

                        callback.Invoke(null, response.AsString("Unknown error"));
                        return;
                    }

                    // Parse account info
                    var accountInfoPacket = response.Deserialize(new AccountInfoPacket());

                    AccountInfo = new ClientAccountInfo()
                    {
                        Id               = accountInfoPacket.Id,
                        Username         = accountInfoPacket.Username,
                        Email            = accountInfoPacket.Email,
                        PhoneNumber      = accountInfoPacket.PhoneNumber,
                        Facebook         = accountInfoPacket.Facebook,
                        Token            = accountInfoPacket.Token,
                        IsAdmin          = accountInfoPacket.IsAdmin,
                        IsGuest          = accountInfoPacket.IsGuest,
                        IsEmailConfirmed = accountInfoPacket.IsEmailConfirmed,
                        Properties       = accountInfoPacket.Properties,
                    };

                    // If RememberMe is checked on and we are not guset, then save auth token
                    if (RememberMe && !AccountInfo.IsGuest && !string.IsNullOrEmpty(AccountInfo.Token))
                    {
                        SaveAuthToken(AccountInfo.Token);
                    }
                    else
                    {
                        ClearAuthToken();
                    }

                    IsSignedIn = true;

                    callback.Invoke(AccountInfo, null);

                    OnSignedInEvent?.Invoke();
                });
            }, connection);
        }
Beispiel #22
0
 /// <summary>
 /// Sends a generic login request
 /// </summary>
 /// <param name="data"></param>
 /// <param name="callback"></param>
 public void SignIn(MstProperties data, SignInCallback callback)
 {
     SignIn(data, callback, Connection);
 }
Beispiel #23
0
 /// <summary>
 /// Sends a login request, using given credentials
 /// </summary>
 public void SignInWithPhoneNumber(string phoneNumber, SignInCallback callback)
 {
     SignInWithPhoneNumber(phoneNumber, callback, Connection);
 }
Beispiel #24
0
 /// <summary>
 /// Sends a login request, using given credentials
 /// </summary>
 public void SignInWithEmail(string email, SignInCallback callback)
 {
     SignInWithEmail(email, callback, Connection);
 }
Beispiel #25
0
 /// <summary>
 /// Sends a login request, using given credentials
 /// </summary>
 public void SignIn(string username, string password, SignInCallback callback)
 {
     SignIn(username, password, callback, Connection);
 }
Beispiel #26
0
        public async Task <IActionResult> Callback([FromBody] SignInCallback callback)
        {
            await _contactsApiClient.Callback(callback);

            return(Ok());
        }
Beispiel #27
0
 /// <summary>
 /// Sends a login request, using given credentials
 /// </summary>
 public void SignInWithLoginAndPassword(string username, string password, SignInCallback callback)
 {
     SignInWithLoginAndPassword(username, password, callback, Connection);
 }
Beispiel #28
0
 /// <summary>
 /// Sends a request to server, to log in as a guest
 /// </summary>
 /// <param name="callback"></param>
 public void SignInAsGuest(SignInCallback callback)
 {
     SignInAsGuest(callback, Connection);
 }
Beispiel #29
0
 /// <summary>
 /// Sends a login request, using given token
 /// </summary>
 public void SignInWithToken(string token, SignInCallback callback)
 {
     SignInWithToken(token, callback, Connection);
 }
Beispiel #30
0
 /// <summary>
 /// Sends a request to server, to log in with auth token
 /// </summary>
 /// <param name="callback"></param>
 public void SignInWithToken(SignInCallback callback)
 {
     SignInWithToken(callback, Connection);
 }