Exemplo n.º 1
0
        public XHRResponse <_Token> Login(_Credentials data)
        {
            XHRResponse <_Token> result = new XHRResponse <_Token>();

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    client.BaseAddress = new Uri($"https://{_configuration["Auth0:Domain"]}/");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "oauth/token"))
                    {
                        var body = new
                        {
                            client_id     = _configuration["Auth0:ClientId"],
                            client_secret = _configuration["Auth0:ClientSecret"],
                            grant_type    = "password",
                            scope         = "openid profile email",
                            username      = data.Username,
                            password      = data.Password
                        };

                        request.Content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
                        HttpResponseMessage response = client.SendAsync(request).Result;
                        ThrowExceptionIfHasInvalidCredentials(response.IsSuccessStatusCode);

                        result.Data      = response.Content.ReadAsAsync <_Token>().Result;
                        result.Succeeded = true;
                    }
                }
            }
            catch (Exception ex)
            {
                result.Message   = "Unable to authenticate user.";
                result.Succeeded = false;
            }

            return(result);
        }
Exemplo n.º 2
0
 public IActionResult Login(_Credentials data)
 {
     return(Ok(_authenticationService.Login(data)));
 }
 public void Dispose()
 {
     _theObject = null;
 }
            internal static _Credentials GetObject(MfsOperations parent)
            {
                if (_theObject == null) {
                    _theObject = new _Credentials (parent);
                }

                return _theObject;
            }
Exemplo n.º 5
0
 private void LoadSubobjects()
 {
     FileObj = _File.GetObject (this);
     DocumentObj = _Document.GetObject (this);
     AspectObj = _Aspect.GetObject (this);
     AspectGroupObj = _AspectGroup.GetObject (this);
     BriefcaseObj = _Briefcase.GetObject (this);
     CollectionObj = _Collection.GetObject (this);
     NoteObj = _Note.GetObject (this);
     UrlObj = _Url.GetObject (this);
     VCardObj = _VCard.GetObject (this);
     SfdObj = _Sfd.GetObject (this);
     RelationObj = _Relation.GetObject (this);
     ArchiveObj = _Archive.GetObject (this);
     BookmarkObj = _Bookmark.GetObject (this);
     IndexObj = _Index.GetObject (this);
     MasterPasswordObj = _MasterPassword.GetObject (this);
     CredentialsObj = _Credentials.GetObject (this);
 }