public ActionResult LogOn(AccountLogOnModel model)
{
if (ModelState.IsValid)
{
#region Authenticator
AuthenticatorManager authenticatorManager = new AuthenticatorManager();
Authenticator authenticator = authenticatorManager.GetAuthenticatorById(model.AuthenticatorList.Id);
Assembly assembly = Assembly.Load(authenticator.AssemblyPath);
Type type = assembly.GetType(authenticator.ClassPath);
#endregion Authenticator
#region AuthenticationManager
IAuthenticationManager authenticationManager = (IAuthenticationManager)Activator.CreateInstance(type, authenticator.ConnectionString);
#endregion AuthenticationManager
if (authenticationManager.ValidateUser(model.Username, model.Password))
{
SubjectManager subjectManager = new SubjectManager();
if (!subjectManager.ExistsUsernameWithAuthenticatorId(model.Username, model.AuthenticatorList.Id))
{
subjectManager.CreateUser(model.Username, model.AuthenticatorList.Id);
}
FormsAuthentication.SetAuthCookie(model.Username, false);
return Json(new { success = true });
}
else
{
ModelState.AddModelError("", "The Username or Password provided is incorrect.");
}
}
return PartialView("_LogOnPartial", model);
}