Exemple #1
0
        // GET: LogIn
        public async Task <string> Index(string email, string password, string username, string mobile)
        {
            try
            {
                var body = new AuthenticationModel
                {
                    ApiKey      = AppId.ToString(),
                    Email       = email,
                    Password    = password,
                    UserName    = username,
                    MobilePhone = mobile
                };

                var tokenResponse = await tokenClient.GetTokenAsync(body);

                if (tokenResponse.StatusCode == HttpStatusCode.OK)
                {
                    var claims = await tokenClient.GetClaimsAsync(tokenResponse.AuthToken);

                    return(tokenResponse.AuthToken + "<br/>" + JsonConvert.SerializeObject(claims));
                }

                // set a query string param so UX can know unauth. See if you can use regular status code
                Response.Redirect("/?l=f");
                return(string.Empty);
            }
            catch (Exception ex)
            {
                return("An exception occured" + ex.Message);
            }
        }