I think you did not understand the question I need another method like Authenticate in any Controller which should accept no input and but it has to be give me a Token
Is it possible in ASP.net ZERO ?
using System;
using System.Threading.Tasks;
using System.Web.Http;
using Abp.Authorization.Users;
using Abp.UI;
using Abp.Web.Models;
using Microsoft.Owin.Infrastructure;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.OAuth;
using DinePlan.DineConnect.Authorization;
using DinePlan.DineConnect.Authorization.Roles;
using DinePlan.DineConnect.Authorization.Users;
using DinePlan.DineConnect.MultiTenancy;
using DinePlan.DineConnect.WebApi.Models;
namespace DinePlan.DineConnect.WebApi.Controllers
{
public class AccountController : DineConnectApiControllerBase
{
public static OAuthBearerAuthenticationOptions OAuthBearerOptions { get; private set; }
private readonly UserManager _userManager;
private readonly AbpLoginResultTypeHelper _abpLoginResultTypeHelper;
static AccountController()
{
OAuthBearerOptions = new OAuthBearerAuthenticationOptions();
}
public AccountController(
UserManager userManager,
AbpLoginResultTypeHelper abpLoginResultTypeHelper)
{
_userManager = userManager;
_abpLoginResultTypeHelper = abpLoginResultTypeHelper;
}
[HttpPost]
public async Task<AjaxResponse> Authenticate(LoginModel loginModel)
{
CheckModelState();
var loginResult = await GetLoginResultAsync(
loginModel.UsernameOrEmailAddress,
loginModel.Password,
loginModel.TenancyName
);
var ticket = new AuthenticationTicket(loginResult.Identity, new AuthenticationProperties());
var currentUtc = new SystemClock().UtcNow;
ticket.Properties.IssuedUtc = currentUtc;
ticket.Properties.ExpiresUtc = currentUtc.Add(TimeSpan.FromMinutes(30));
return new AjaxResponse(OAuthBearerOptions.AccessTokenFormat.Protect(ticket));
}
private async Task<AbpUserManager<Tenant, Role, User>.AbpLoginResult> GetLoginResultAsync(string usernameOrEmailAddress, string password, string tenancyName)
{
var loginResult = await _userManager.LoginAsync(usernameOrEmailAddress, password, tenancyName);
switch (loginResult.Result)
{
case AbpLoginResultType.Success:
return loginResult;
default:
throw _abpLoginResultTypeHelper.CreateExceptionForFailedLoginAttempt(loginResult.Result, usernameOrEmailAddress, tenancyName);
}
}
protected virtual void CheckModelState()
{
if (!ModelState.IsValid)
{
throw new UserFriendlyException("Invalid request!");
}
}
}
}
Please execute this and let me know
Thanks
I have tried that and it is not working
Could you please check it ?
Please reply
I am waiting for the reply since last week
I will put it like this
I want to create one more method in the controller like
Account/Authenticate
How to achieve ?
Account/Authenticate does not expect Token.
How to Set it ?
Please show me a example
Thanks
Folks Any update ?
Where to change the Size for all the modals ?
Dear Sir
How to set the Modal Width for all the Modal in the application in SPA ?
Thanks again.
I have read about Domain Services
<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Domain-Services">http://www.aspnetboilerplate.com/Pages/ ... n-Services</a>
I guess we should have business validation at this place.
Could you please tell me where to keep the file (Which Project) ?
Thanks