Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
- {
- AccountLogin LogCredentials = new AccountLogin();
- LogCredentials.UserName = context.UserName;
- LogCredentials.Password = context.Password;
- LogCredentials.IPAddress = "::1";
- string webHost = Convert.ToString(WebConfigurationManager.AppSettings["webHost"]);
- context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { webHost });
- ProviderLoginResponse providerLoginResponse = MembershipService.UserLogin(LogCredentials);
- if (providerLoginResponse.LoginStatus != "Y")
- {
- context.SetError("invalid_grant", "The user name or password is incorrect.");
- return Task.FromResult<object>(null);
- }
- var claims = new List<Claim>()
- {
- new Claim(ClaimTypes.Sid, Convert.ToString(providerLoginResponse.UserID)),
- new Claim(ClaimTypes.Name, providerLoginResponse.UserName),
- new Claim(ClaimTypes.Email, providerLoginResponse.UserEmail)
- };
- ClaimsIdentity oAuthIdentity = new ClaimsIdentity(claims,
- Startup.OAuthOptions.AuthenticationType);
- AuthenticationProperties properties = CreateProperties(providerLoginResponse);
- AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties);
- context.Validated(ticket);
- return Task.FromResult<object>(null);
- }
- [HttpGet]`
- [Route("GetColumn")]
- public HttpResponseMessage GetColumn(HttpRequestMessage request)
- {
- string tableName = "";
- HttpResponseMessage response = null;
- try
- {
- var clientList = _settingsService.GetColumns(tableName);
- response = request.CreateResponse(HttpStatusCode.OK, new APIResponse { Status = true, Data = clientList, Message = Messages.Saved_Success });
- }
- catch (Exception ex)
- {
- response = request.CreateResponse(HttpStatusCode.OK, new APIResponse { Status = false, Data = null, Message = ex.Message });
- }
- return response;
- }`
- function GetColumn(data, cb) {
- var token = sessionStorage.getItem('accessToken');
- var headers = {};
- if (token) {
- headers.Authorization = 'Bearer ' + token;
- }
- $.ajax({
- type: 'GET',
- url: "api/Settings/GetColumn",
- headers: headers
- }).done(function (data) {
- cb(data);
- }).fail(function (Res) {
- cb(Res);
- });
- };
Add Comment
Please, Sign In to add comment