Exemple #1
0
        public static async Task <Session> LoginAsync(this AccountClient client, string username, string password)
        {
            Session = (await client.LoginAsync(new LoginDto()
            {
                UserName = username, Password = password
            })).Data;
            var token = Session.Token;

            HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token.Access_token);
            ApiResultOfUserInfoDto userInfoDto = await client.MyInfoAsync();

            MyInfo = userInfoDto.Data;
            return(Session);
        }
Exemple #2
0
        public static async Task <Session> LoginAsync(this AccountClient client, string username, string password)
        {
            Session = await client.LoginAsync(new LoginDto()
            {
                UserName = username, Password = password
            });

            var token = Session.Token;

            HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.Access_token}");
            ApiResultOfUserInfoDto userInfoDto = await client.MyInfoAsync();

            MyInfo = userInfoDto.Data;
            return(Session);
        }
Exemple #3
0

        
Exemple #4
0
        public async Task <bool> RegisterAsync(string customer, string username, string password, string phoneNumber)
        {
            try
            {
                _act_client = Create <AccountClient>();
                _result     = await _act_client.RegisterAsync(new RegisterDto()
                {
                    Customer = customer, Email = username, Password = password, PhoneNumber = phoneNumber
                });

                HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {Token.Access_token}");
                ApiResultOfUserInfoDto userInfoDto = await _act_client.MyInfoAsync();

                MyInfo = userInfoDto.Data;
            }
            catch (Exception ex)
            {
                throw new Exception("Register error ", ex);
            }
            return((bool)(_result?.SignIn.Succeeded));
        }