Light12306/ChatRoomServer.Www/Areas/Api/Controllers/AccountController.cs

35 lines
761 B
C#
Raw Permalink Normal View History

2015-07-13 21:18:04 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace ChatRoomServer.Www.Areas.Api.Controllers
{
using System.Web.Security;
[RoutePrefix("api/account")]
public class AccountController : ApiController
{
[AllowAnonymous]
[HttpPost]
[Route("login")]
public object Login([FromBody]Dictionary<string, string> data)
{
var password = data.GetValue("password");
var succeed = password == System.Configuration.ConfigurationManager.AppSettings["control_pwd"];
if (succeed)
{
FormsAuthentication.SetAuthCookie("admin", false);
}
return new
{
success = succeed,
message = succeed ? "登录成功!" : "密码错误!"
};
}
}
}