2016-01-05 17:14:10 +08:00
|
|
|
|
using System;
|
2015-11-30 17:44:42 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
2016-04-11 23:46:33 +08:00
|
|
|
|
using System.Web.Security;
|
2015-11-30 17:44:42 +08:00
|
|
|
|
using OpenAuth.App;
|
2016-01-02 23:16:22 +08:00
|
|
|
|
using OpenAuth.Mvc.Models;
|
2015-11-30 17:44:42 +08:00
|
|
|
|
|
|
|
|
|
namespace OpenAuth.Mvc.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class LoginController : Controller
|
|
|
|
|
{
|
|
|
|
|
private LoginApp _app;
|
|
|
|
|
|
|
|
|
|
public LoginController()
|
|
|
|
|
{
|
2015-12-16 22:52:23 +08:00
|
|
|
|
_app = AutofacExt.GetFromFac<LoginApp>();
|
2015-11-30 17:44:42 +08:00
|
|
|
|
}
|
|
|
|
|
// GET: Login
|
|
|
|
|
public ActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult Index(string username, string password)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2016-04-21 10:54:05 +08:00
|
|
|
|
_app.Login(username, password);
|
2015-11-30 17:44:42 +08:00
|
|
|
|
return RedirectToAction("Index", "Home");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2016-01-02 23:16:22 +08:00
|
|
|
|
var response = new BjuiResponse
|
|
|
|
|
{
|
|
|
|
|
statusCode = "300",
|
|
|
|
|
message = e.Message
|
|
|
|
|
};
|
|
|
|
|
return View(response);
|
2015-11-30 17:44:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-12-01 17:30:24 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 开发者登陆
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ActionResult LoginByDev()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2016-04-21 10:54:05 +08:00
|
|
|
|
_app.LoginByDev();
|
2015-12-01 17:30:24 +08:00
|
|
|
|
return RedirectToAction("Index", "Home");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2016-04-21 10:54:05 +08:00
|
|
|
|
return RedirectToAction("Index", "Login");
|
2015-12-01 17:30:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult Logout()
|
|
|
|
|
{
|
2016-04-21 10:54:05 +08:00
|
|
|
|
|
|
|
|
|
FormsAuthentication.SignOut();
|
2015-12-01 17:30:24 +08:00
|
|
|
|
return RedirectToAction("Index", "Login");
|
|
|
|
|
}
|
2015-11-30 17:44:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|