我想帮助用户从我的服务登录,所以我不是直接发布到'/ auth / basics'或'/ auth / credentials'链接,而是从我的代码中执行此操作:
public class LoginService : Service {
public LoginResponse Post(Login req) {
var authService = ServiceStack.WebHost.Endpoints.AppHostBase.Instance.Container.Resolve<AuthService>();
authService.RequestContext = new HttpRequestContext(
System.Web.HttpContext.Current.Request.ToRequest(),
System.Web.HttpContext.Current.Response.ToResponse(),
null
);
authResponse = AuthService.Authenticate(
new Auth{
UserName = req.UserName,
Password = req.Password,
RememberMe = true
});
if(authResponse.UserName != null) {
//sccessful
//and does it automatically write session to cookies too?
//or do I need to write to session manually?
}
}
}
这是我到目前为止所想到的。这是正确的方法吗?我想和你确认一下。