123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- using EMIS.CommonLogic.SystemServices;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Web.Mvc;
- using EMIS.Web.Controls;
- using EMIS.ViewModel;
- using EMIS.ViewModel.SystemView;
- namespace EMIS.Web.ServiceControllers.SystemManage
- {
- public class UserServicesController : Controller
- {
- //
- // GET: /UserServices/
- public IUserServices UserServices { get; set; }
- public IWechatMPServices WechatMPServices { get; set; }
- public IMailVerifyServices MailVerifyServices { get; set; }
- public ActionResult Login(string loginID, string password, string openID)
- {
- password = Bowin.Common.Utility.StringEx.MD5(password);
- var isLogined = UserServices.Login(loginID, password);
- bool isCanLogin = UserServices.LoginHistory(loginID, isLogined);
-
- try
- {
- if (!isCanLogin)
- {
- throw new Exception("当天登陆失败次数超过5次,请明天再试或联系管理员。");
- }
- if (openID != null && openID != "null")
- {
- WechatMPServices.BindOpenID(loginID, openID);
- }
- else if (openID == "null")
- {
- throw new Exception("微信openid获取失败,请关注公众号之后,刷新页面重试!如果已经关注公众号,请联系老师或管理员。");
- }
- }
- catch(Exception ex)
- {
- return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
- }
- return Json(new ReturnMessage { IsSuccess = isLogined, Message = "密码错误或不存在该账户!(注意:如密码连续输入错误5次以上账号将被锁定)" });
- }
-
- public ActionResult LoginP(string loginID, string password)
- {
- password = Bowin.Common.Utility.StringEx.MD5(password);
- return new JSONPResult { Data = UserServices.Login(loginID, password) };
- }
- public ActionResult Regist(RegistView model, string openID)
- {
- try
- {
- UserServices.StudentRegist(model);
- try
- {
- if (openID != null)
- {
- WechatMPServices.BindOpenID(model.LoginID, openID);
- }
- }
- catch
- {
- }
- return Json(new ReturnMessage<Guid?> { IsSuccess = true, Message = "注册成功", Data = model.UserID });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage { IsSuccess = false, Message = "注册失败,原因:" + ex.Message });
- }
- }
- public ActionResult UnBind(string openID)
- {
- if (openID != null)
- {
- try
- {
- WechatMPServices.UnBindOpenID(openID);
- return Json(new ReturnMessage { IsSuccess = true, Message = "解除绑定成功" });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage { IsSuccess = false, Message = "解除绑定失败,原因:" + ex.Message });
- }
- }
- else
- {
- return Json(new ReturnMessage { IsSuccess = true, Message = "解除绑定成功" });
- }
- }
- //[HttpPost]
- //public ActionResult ForgotPassword(string LoginID)
- //{
- // var result = new ReturnMessage { IsSuccess = true, Message = "邮件发送成功,请查收。" };
- // //string loginID = Request.Form["LoginID"];
- // string failUrl = Url.Content("~/Account/ForgotPassword?LoginID=" + LoginID);
- // string successUrl = Url.Content("~/Account/Login");
- // var user = UserServices.GetUserByLoginID(LoginID);
- // if (user == null)
- // {
- // result.IsSuccess = false;
- // result.Message = "用户名输入错误。";
- // return Json(result);
- // }
- // var url = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Host + ":" + HttpContext.Request.Url.Port + Url.Content("~/").TrimEnd('/');
- // try
- // {
- // var email = UserServices.GetUserEmail(user.UserID);
- // if (email == null)
- // {
- // result.IsSuccess = false;
- // result.Message = "用户并没有注册电子邮箱信息。";
- // return Json(result);
- // }
- // MailVerifyServices.SendVerifyMail(url, user.UserID, email);
- // return Json(result);
- // }
- // catch (Exception ex)
- // {
- // result.IsSuccess = false;
- // result.Message = ex.Message;
- // return Json(result);
- // }
- //}
- }
- }
|