Permalink
Browse files

jquery login posting working

  • Loading branch information...
ehelin committed Oct 15, 2018
1 parent 07e28af commit e94274d979c194d2453c033e3950002825173c87
@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Shared.interfaces;
using TgimbaNetCoreWeb.Dto;
namespace TgimbaNetCoreWeb.Controllers
{
@@ -45,11 +46,11 @@ public string Login(string user, string pass)
}
[HttpPost]
public string JQueryLogin([FromQuery] string user, string pass)
public string JQueryLogin([FromBody] User user)
{
WebClient client = new WebClient(this.service);
string token = client.Login(user, pass);
string token = client.Login(user.Username, user.Password);
return token;
}
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TgimbaNetCoreWeb.Dto
{
public class User
{
public string Username { get; set; }
public string Password { get; set; }
}
}
@@ -4,16 +4,17 @@
var token = false;
var base64UserName = btoa(params[0]);
var base64PassWord = btoa(params[1]);
var formData = new FormData();
formData.append("user", base64UserName);
formData.append("pass", base64PassWord);
var jsonData = JSON.stringify
({
Username:base64UserName,
Password:base64PassWord
});
token = CallService('/Home/JQueryLogin',
'post',
'application/json; charset=utf-8',
formData);
'post',
'application/json; charset=utf-8',
jsonData);
if (token && token.length > 0){
alert('JQuery logged in!');

0 comments on commit e94274d

Please sign in to comment.