35 lines
761 B
C#
35 lines
761 B
C#
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 ? "登录成功!" : "密码错误!"
|
|
};
|
|
}
|
|
}
|
|
}
|