Quellcode durchsuchen

【修改】忘记密码、首次登录、绑解微信、等发送短信功能;

西昌分支
dyy vor 4 Monaten
Ursprung
Commit
9fda6e1170
12 geänderte Dateien mit 741 neuen und 99 gelöschten Zeilen
  1. +45
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserBLL.cs
  2. +5
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserEntity.cs
  3. +11
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserIBLL.cs
  4. +51
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs
  5. +230
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs
  6. +4
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
  7. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/BaseApi.cs
  8. +252
    -7
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs
  9. +53
    -29
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs
  10. +85
    -55
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/WeixinApi.cs
  11. +3
    -4
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/firstLogin.vue
  12. +1
    -1
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/wxLogin.vue

+ 45
- 1
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserBLL.cs Datei anzeigen

@@ -497,7 +497,28 @@ namespace Learun.Application.Organization
}
}
}

/// <summary>
/// 记录已登录标记
/// </summary>
/// <param name="id"></param>
public void UpdateHaveLogMark(string id)
{
try
{
userService.UpdateHaveLogMark(id);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
/// <summary>
/// 获取用户数据
/// </summary>
@@ -1109,6 +1130,29 @@ namespace Learun.Application.Organization
}
}
}
/// <summary>
/// 修改手机号
/// </summary>
/// <param name="keyValue"></param>
/// <param name="mobile"></param>
public void UpdateMobile(string keyValue, string mobile)
{
try
{
userService.UpdateMobile(keyValue, mobile);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}
#endregion

#region 验证数据


+ 5
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserEntity.cs Datei anzeigen

@@ -240,6 +240,11 @@ namespace Learun.Application.Organization
/// </summary>
[Column("F_MODIFYPWDDATE")]
public DateTime? F_ModifyPwdDate { get; set; }
/// <summary>
/// 是否已登录标记
/// </summary>
[Column("F_HAVELOGMARK")]
public bool? F_HaveLogMark { get; set; }
#endregion

#region 扩展操作


+ 11
- 0
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserIBLL.cs Datei anzeigen

@@ -155,6 +155,12 @@ namespace Learun.Application.Organization
/// 解绑微信
/// </summary>
void DoUnbundWeiXin(string keyValue);
/// <summary>
/// 修改手机号
/// </summary>
/// <param name="keyValue"></param>
/// <param name="mobile"></param>
void UpdateMobile(string keyValue, string mobile);
#endregion

#region 验证数据
@@ -202,6 +208,11 @@ namespace Learun.Application.Organization
IEnumerable<UserEntity> GetAdminList();

void UpdateIp(string ip, string id);
/// <summary>
/// 记录已登录标记
/// </summary>
/// <param name="id"></param>
void UpdateHaveLogMark(string id);
void GetImgForDC(string userId);
UserEntity GetEntityByWeixinOpenIdPC(string openId);



+ 51
- 1
Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs Datei anzeigen

@@ -873,7 +873,35 @@ namespace Learun.Application.Organization
}
}
}

/// <summary>
/// 修改手机号
/// </summary>
/// <param name="keyValue"></param>
/// <param name="mobile"></param>
public void UpdateMobile(string keyValue, string mobile)
{
try
{
var userEntity = this.BaseRepository().FindEntity<UserEntity>(keyValue);
if (userEntity != null)
{
userEntity.F_Mobile = mobile;
userEntity.Modify(keyValue);
this.BaseRepository().Update(userEntity);
}
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
public void UpdateIp(string ip, string id)
{
try
@@ -892,6 +920,28 @@ namespace Learun.Application.Organization
}
}
}
/// <summary>
/// 记录已登录标记
/// </summary>
/// <param name="id"></param>
public void UpdateHaveLogMark(string id)
{
try
{
this.BaseRepository().ExecuteBySql("update LR_Base_User set F_HaveLogMark=1 where F_UserId='" + id + "' ");
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

/// <summary>
/// 获取用户头像,取empinfo照片


+ 230
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs Datei anzeigen

@@ -18,6 +18,10 @@ using Quanjiang.DigitalScholl.WebLicense;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Newtonsoft.Json;
using Learun.Application.OA.Email.EmailSend;
using System.Collections.Generic;
using Quanjiang.DigitalScholl.SendSms;
using Learun.Cache.Factory;
using Learun.Cache.Base;

namespace Learun.Application.Web.Controllers
{
@@ -41,6 +45,8 @@ namespace Learun.Application.Web.Controllers
WeChatDevelopIBLL weChatDevelopIbll = new WeChatDevelopBLL();
private Sys_DefaultPwdConfigIBLL Sys_DefaultPwdConfigIbll = new Sys_DefaultPwdConfigBLL();
private EmailSendIBLL emailSendIBLL = new EmailSendBLL();
private readonly ISms yixintongSms = new YixintongSms();
private ICache redisCache = CacheFactory.CaChe();
#endregion

#region 视图功能
@@ -596,6 +602,8 @@ namespace Learun.Application.Web.Controllers
}
else
{
//记录已登录标记
userBll.UpdateHaveLogMark(userEntity.F_UserId);
//记录ip
userBll.UpdateIp(GetIP(), userEntity.F_UserId);
OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_PC", null);//写入缓存信息
@@ -992,6 +1000,8 @@ namespace Learun.Application.Web.Controllers
logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : userEntity.F_Account;
logEntity.F_Module = Config.GetValue("SoftName");
logEntity.F_Description = "PC端微信登录";
//记录已登录标记
userBll.UpdateHaveLogMark(userEntity.F_UserId);
//记录ip
userBll.UpdateIp(GetIP(), userEntity.F_UserId);
OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_PC", null);//写入缓存信息
@@ -1021,6 +1031,8 @@ namespace Learun.Application.Web.Controllers
logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : userEntity.F_Account;
logEntity.F_Module = Config.GetValue("SoftName");
logEntity.F_Description = "PC端微信登录";
//记录已登录标记
userBll.UpdateHaveLogMark(userEntity.F_UserId);
//记录ip
userBll.UpdateIp(GetIP(), userEntity.F_UserId);
OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_PC", null);//写入缓存信息
@@ -1119,6 +1131,8 @@ namespace Learun.Application.Web.Controllers
}
//更新openid
userBll.UpdateWeixinOpenIdPC(userEntity.F_UserId, WeixinOpenId);
//记录已登录标记
userBll.UpdateHaveLogMark(userEntity.F_UserId);
//记录ip
userBll.UpdateIp(GetIP(), userEntity.F_UserId);
OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_PC", null); //写入缓存信息
@@ -1165,6 +1179,8 @@ namespace Learun.Application.Web.Controllers
{
//更新openid
userBll.UpdateWeixinOpenIdPC(userEntity.F_UserId, WeixinOpenId);
//记录已登录标记
userBll.UpdateHaveLogMark(userEntity.F_UserId);
//记录ip
userBll.UpdateIp(GetIP(), userEntity.F_UserId);
OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_PC", null); //写入缓存信息
@@ -1195,6 +1211,220 @@ namespace Learun.Application.Web.Controllers
return Content(response);
}

#endregion

#region 短信发送、校验

/// <summary>
/// 忘记密码
/// </summary>
/// <returns></returns>
public ActionResult ForgotPassword()
{
return View();
}
/// <summary>
/// 首次登录-手机号
/// </summary>
/// <returns></returns>
public ActionResult FirstLoginByMobile()
{
return View();
}
/// <summary>
/// 发送短信验证码
/// </summary>
/// <param name="codeType">发送短信类型:忘记密码forgetpwd,首次登录firstlogin,绑定微信bindwx,解绑微信unbindwx,修改手机号modifymobile,;</param>
/// <param name="phone">手机号</param>
/// <returns></returns>
[HttpPost]
public ActionResult Sendcode(string codeType, string phone)
{
if (string.IsNullOrEmpty(codeType))
{
return Fail("未指定短信类型。");
}
UserEntity userEntity = null;
userEntity = userBll.GetEntityByMobile(phone);
if (userEntity == null)
{
return Fail("用户不存在!");
}
if (string.IsNullOrEmpty(userEntity.F_Mobile))
{
return Fail("用户手机号不存在!");
}
if (codeType == "firstlogin" && userEntity.F_HaveLogMark == true)
{
return Fail("当前用户非首次登录,请使用账号密码进行登录!");
}
//todo:待取消注释
//string raRndNum = Learun.Util.CommonHelper.RndNum(6);
string raRndNum = "123456";
var listStr = new List<string>();
var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。";
listStr.Add(str1);
//todo:待开发短信平台
//var result = yixintongSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr);
//if (result.Result.code == "0")
if (true)
{
redisCache.Write<string>("sendcodeinpc_" + codeType + "_" + userEntity.F_Mobile, raRndNum, new TimeSpan(0, 5, 0));
//日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 3;
logEntity.F_SourceObjectId = codeType;
logEntity.F_OperateTypeId = "sms";
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 200;
logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + raRndNum;
logEntity.WriteLog();
return Success("短信发送成功:");// + result.Result.message);
}
else
{
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 4;
logEntity.F_SourceObjectId = codeType;
logEntity.F_OperateTypeId = "sms";
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 400;
//logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
//logEntity.F_Description = "短信发送:" + userEntity.F_Mobile;
//logEntity.WriteLog();
//return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
}
}
/// <summary>
/// 短信验证码校验
/// </summary>
/// <param name="codeType">发送短信类型</param>
/// <param name="phone">手机号</param>
/// <param name="verifycode">验证码</param>
/// <returns></returns>
[HttpPost]
public ActionResult LoginCodeVerify(string codeType, string phone, string verifycode)
{
if (string.IsNullOrEmpty(codeType))
{
return Fail("未指定短信类型。");
}
if (string.IsNullOrEmpty(phone))
{
return Fail("手机号不能为空。");
}
var code = redisCache.Read<string>("sendcodeinpc_" + codeType + "_" + phone);
if (!string.IsNullOrEmpty(code) && code == verifycode)
{
return Success("验证成功。");
}
else
{
return Fail("验证失败,验证码错误或已失效。");
}

}
/// <summary>
/// 忘记密码:修改密码
/// </summary>
/// <param name="phone"></param>
/// <param name="newpassword"></param>
/// <returns></returns>
[HttpPost]
public ActionResult ForgotPasswordHandle(string phone, string newpassword)
{
UserEntity userEntity = userBll.GetEntityByMobile(phone);
if (userEntity == null)
{
return Fail("用户不存在");
}
userBll.setPassword(userEntity.F_UserId, newpassword);

return Success("密码修改成功");
}
/// <summary>
/// 首次登录:手机号登录
/// </summary>
/// <param name="codeType">发送短信类型</param>
/// <param name="phone">手机号</param>
/// <param name="verifycode">验证码</param>
/// <returns></returns>
[HttpPost]
public ActionResult LoginByMobile(string codeType, string phone, string verifycode)
{
//短信验证码校验
if (string.IsNullOrEmpty(codeType))
{
return Fail("未指定短信类型。");
}
if (string.IsNullOrEmpty(phone))
{
return Fail("手机号不能为空。");
}
var code = redisCache.Read<string>("sendcodeinpc_" + codeType + "_" + phone);
if (!string.IsNullOrEmpty(code) && code == verifycode)
{
//return Success("验证成功。");
#region 内部账户验证
UserEntity userEntity = userBll.GetEntityByMobile(phone);
if (userEntity == null)
{
return Fail("用户不存在!");
}
if (userEntity.F_EnabledMark != 1)
{
return Fail("账户被系统锁定,请联系管理员!");
}
userEntity.LoginOk = true;
#region 写入日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 1;
logEntity.F_OperateTypeId = ((int)OperationType.Login).ToString();
logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Login);
logEntity.F_OperateAccount = userEntity.F_Account + "(" + userEntity.F_RealName + ")";
logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : userEntity.F_Account;
logEntity.F_Module = Config.GetValue("SoftName");
logEntity.F_Description = "PC端-首次登录";
#endregion

if (!userEntity.LoginOk)//登录失败
{
//写入日志
logEntity.F_ExecuteResult = 0;
logEntity.F_ExecuteResultJson = "登录失败:" + userEntity.LoginMsg;
logEntity.WriteLog();
return Fail(userEntity.LoginMsg);
}
else
{
//记录已登录标记
userBll.UpdateHaveLogMark(userEntity.F_UserId);
//记录ip
userBll.UpdateIp(GetIP(), userEntity.F_UserId);
OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_PC", null);//写入缓存信息
//写入日志
logEntity.F_ExecuteResult = 1;
logEntity.F_ExecuteResultJson = "登录成功";
logEntity.WriteLog();
//结果
var succresult = new SuccResult() {
pwd = true
};
return Success(succresult);
}
#endregion
}
else
{
return Fail("验证失败,验证码错误或已失效。");
}
}


#endregion

/// <summary>


+ 4
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj Datei anzeigen

@@ -7196,6 +7196,10 @@
<Project>{1d192591-b85a-41db-ae3a-4bf9765786c1}</Project>
<Name>Learun.Workflow.Engine</Name>
</ProjectReference>
<ProjectReference Include="..\Quanjiang.DigitalScholl.SendSms\Quanjiang.DigitalScholl.SendSms.csproj">
<Project>{55f0f08d-2a9f-489a-be1b-2eeae80687e6}</Project>
<Name>Quanjiang.DigitalScholl.SendSms</Name>
</ProjectReference>
<ProjectReference Include="..\Quanjiang.DigitalScholl.WebLicense\Quanjiang.DigitalScholl.WebLicense.csproj">
<Project>{4D841EAD-3FD8-4FAC-BC67-C4CE6C0D1181}</Project>
<Name>Quanjiang.DigitalScholl.WebLicense</Name>


+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/BaseApi.cs Datei anzeigen

@@ -180,7 +180,7 @@ namespace Learun.Application.WebApi
ReqParameter req = this.Bind<ReqParameter>();
loginMark = req.loginMark;
token = req.token;
if (path == "/learun/adms/user/login"|| path == "/learun/adms/user/loginbyIdCard" || path == "/" || path == "/bgimg" || path == "/learun/adms/user/img" || path == "/learun/adms/desktop/img"||path== "/learun/adms/user/imgfordc" || path == "/quanjiang/sso/authorize")
if (path == "/learun/adms/user/login"|| path == "/learun/adms/user/loginbyIdCard" || path == "/" || path == "/bgimg" || path == "/learun/adms/user/img" || path == "/learun/adms/desktop/img"||path== "/learun/adms/user/imgfordc" || path == "/quanjiang/sso/authorize" || path == "/learun/adms/user/loginByMobile")
{// 登录接口,默认页面接口不做权限验证处理
return null;
}


+ 252
- 7
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs Datei anzeigen

@@ -6,6 +6,7 @@ using Learun.Cache.Factory;
using Learun.Util;
using Learun.Util.Operat;
using Nancy;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
@@ -29,10 +30,13 @@ namespace Learun.Application.WebApi
{
Post["/login"] = Login;
Post["/logincodeverify"] = LoginCodeVerify;
Post["/sendcode"] = Sendcode;
Post["/modifypw"] = ModifyPassword;
Post["/modifypwiden"] = ModifyPasswordiden;
Post["/unbundWeiXin"] = DoUnbundWeiXin;
Post["/loginbyIdCard"] = LoginByIdCard;
Post["/updateMobile"] = UpdateMobile;
Post["/loginByMobile"] = LoginByMobile;

Get["/info"] = Info;
Get["/map"] = GetMap;
@@ -51,14 +55,22 @@ namespace Learun.Application.WebApi


/// <summary>
/// 登录二次短信验证
/// 短信验证码校验
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response LoginCodeVerify(dynamic _)
{
MobileVerify mobileVerify = this.GetReqData<MobileVerify>();
var code = redisCache.Read<string>("studentuserlogin_" + mobileVerify.mobile);
if (string.IsNullOrEmpty(mobileVerify.codeType))
{
return Fail("未指定短信类型。");
}
if (string.IsNullOrEmpty(mobileVerify.mobile))
{
return Fail("手机号不能为空。");
}
var code = redisCache.Read<string>("sendcodeinapp_" + mobileVerify.codeType + "_" + mobileVerify.mobile);
if (!string.IsNullOrEmpty(code) && code == mobileVerify.verifycode)
{
return Success("验证成功。");
@@ -69,6 +81,76 @@ namespace Learun.Application.WebApi
}

}
/// <summary>
/// 发送短信验证码
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response Sendcode(dynamic _)
{
LoginModel loginModel = this.GetReqData<LoginModel>();
if (string.IsNullOrEmpty(loginModel.codeType))
{
return Fail("未指定短信类型。");
}
UserEntity userEntity = null;
userEntity = userIBLL.GetEntityByUserId(userInfo.userId);
if (userEntity == null)
{
return Fail("用户不存在!");
}
if (loginModel.codeType == "unbindwx")
{
if (string.IsNullOrEmpty(userEntity.F_Mobile))
{
return Fail("用户手机号不存在!");
}
loginModel.username = userEntity.F_Mobile;
}
if (string.IsNullOrEmpty(loginModel.username))
{
return Fail("手机号不能为空。");
}
//todo:待取消注释
//string raRndNum = Learun.Util.CommonHelper.RndNum(6);
string raRndNum = "123456";
var listStr = new List<string>();
var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。";
listStr.Add(str1);
//todo:待开发短信平台
//var result = yixintongSms.SendSmsToSingle(loginModel.username, SmsType.LoginBind, listStr);
//if (result.Result.code == "0")
if (true)
{
redisCache.Write<string>("sendcodeinapp_" + loginModel.codeType + "_" + loginModel.username, raRndNum, new TimeSpan(0, 5, 0));
//日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 3;
logEntity.F_SourceObjectId = loginModel.codeType;
logEntity.F_OperateTypeId = "sms";
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 200;
logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message;
logEntity.F_Description = "短信发送:" + loginModel.username + " 验证码:" + raRndNum;
logEntity.WriteLog();
return Success("短信发送成功:");// + result.Result.message);
}
else
{
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 4;
logEntity.F_SourceObjectId = loginModel.codeType;
logEntity.F_OperateTypeId = "sms";
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 400;
//logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
//logEntity.F_Description = "短信发送:" + loginModel.username;
//logEntity.WriteLog();
//return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
}
}

/// <summary>
/// 登录接口
@@ -103,6 +185,8 @@ namespace Learun.Application.WebApi
}
else
{
//记录已登录标记
userIBLL.UpdateHaveLogMark(userEntity.F_UserId);
//记录ip
userIBLL.UpdateIp(GetIP(), userEntity.F_UserId);
string token = OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_App", this.loginMark, false);//写入缓存信息
@@ -138,7 +222,7 @@ namespace Learun.Application.WebApi
baseinfo = res.userInfo,
post = postIBLL.GetListByPostIds(res.userInfo.postIds),
role = roleIBLL.GetListByRoleIds(res.userInfo.roleIds),
pwd= pwd
pwd = pwd
};
return Success(jsonData);
}
@@ -180,11 +264,13 @@ namespace Learun.Application.WebApi
{
//新增新生判断
var stuinfobasic = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(userEntity.F_EnCode);
if (stuinfobasic!=null&&stuinfobasic.Grade!="22")
if (stuinfobasic != null && stuinfobasic.Grade != "22")
{
userEntity.LoginMsg = "只有新生支持身份证方式登录";
return Fail(userEntity.LoginMsg);
}
//记录已登录标记
userIBLL.UpdateHaveLogMark(userEntity.F_UserId);
//记录ip
userIBLL.UpdateIp(GetIP(), userEntity.F_UserId);
string token = OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_App", this.loginMark, false);//写入缓存信息
@@ -227,6 +313,104 @@ namespace Learun.Application.WebApi
#endregion
}

/// <summary>
/// 登录接口-首次登录-手机号
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response LoginByMobile(dynamic _)
{
LoginModel loginModel = this.GetReqData<LoginModel>();
//短信验证码校验
if (string.IsNullOrEmpty(loginModel.codeType))
{
return Fail("未指定短信类型。");
}
if (string.IsNullOrEmpty(loginModel.username))
{
return Fail("手机号不能为空。");
}
var code = redisCache.Read<string>("sendcodeinapp_" + loginModel.codeType + "_" + loginModel.username);
if (!string.IsNullOrEmpty(code) && code == loginModel.verifycode)
{
//return Success("验证成功。");
#region 内部账户验证
UserEntity userEntity = userIBLL.GetEntityByMobile(loginModel.username);
if (userEntity == null)
{
return Fail("用户不存在!");
}
if (userEntity.F_EnabledMark != 1)
{
return Fail("账户被系统锁定,请联系管理员!");
}
userEntity.LoginOk = true;

#region 写入日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 1;
logEntity.F_OperateTypeId = ((int)OperationType.Login).ToString();
logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Login);
logEntity.F_OperateAccount = loginModel.username + "(" + userEntity.F_RealName + ")";
logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : loginModel.username;
logEntity.F_Module = Config.GetValue("SoftName");
logEntity.F_Description = "移动端-首次登录";
#endregion

if (!userEntity.LoginOk)//登录失败
{
//写入日志
logEntity.F_ExecuteResult = 0;
logEntity.F_ExecuteResultJson = "登录失败:" + userEntity.LoginMsg;
logEntity.WriteLog();
return Fail(userEntity.LoginMsg);
}
else
{
//记录已登录标记
userIBLL.UpdateHaveLogMark(userEntity.F_UserId);
//记录ip
userIBLL.UpdateIp(GetIP(), userEntity.F_UserId);
string token = OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_App", this.loginMark, false);//写入缓存信息
//写入日志
logEntity.F_ExecuteResult = 1;
logEntity.F_ExecuteResultJson = "登录成功";
logEntity.WriteLog();

//保存用户设备号
userIBLL.UpdateDeviceId(userEntity.F_UserId, loginModel.deviceid);

OperatorResult res = OperatorHelper.Instance.IsOnLine(token, this.loginMark);
res.userInfo.password = null;
res.userInfo.secretkey = null;
var studententity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(userEntity.F_Account);
if (studententity != null)
{
res.userInfo.grade = studententity.Grade;
var majorinfo = majorIbll.GetCdMajorEntityByMajorNo(studententity.MajorNo);
if (majorinfo != null)
{
res.userInfo.majorno = majorinfo.ID ?? "";
}
}
var jsonData = new
{
baseinfo = res.userInfo,
post = postIBLL.GetListByPostIds(res.userInfo.postIds),
role = roleIBLL.GetListByRoleIds(res.userInfo.roleIds),
pwd = true
};
return Success(jsonData);
}
#endregion
}
else
{
return Fail("验证失败,验证码错误或已失效。");
}
}

/// <summary>
/// 获取用户信息
/// </summary>
@@ -300,9 +484,58 @@ namespace Learun.Application.WebApi
/// <returns></returns>
private Response DoUnbundWeiXin(dynamic _)
{
userIBLL.DoUnbundWeiXin(userInfo.userId);
return Success("解绑成功");

MobileVerify mobileVerify = this.GetReqData<MobileVerify>();
if (string.IsNullOrEmpty(mobileVerify.codeType))
{
return Fail("未指定短信类型。");
}
if (mobileVerify.codeType == "unbindwx")
{
mobileVerify.mobile = userIBLL.GetEntityByUserId(userInfo.userId)?.F_Mobile;
}
if (string.IsNullOrEmpty(mobileVerify.mobile))
{
return Fail("手机号不能为空。");
}
var code = redisCache.Read<string>("sendcodeinapp_" + mobileVerify.codeType + "_" + mobileVerify.mobile);
if (!string.IsNullOrEmpty(code) && code == mobileVerify.verifycode)
{
//return Success("验证成功。");
userIBLL.DoUnbundWeiXin(userInfo.userId);
return Success("解绑成功");
}
else
{
return Fail("验证失败,验证码错误或已失效。");
}
}
/// <summary>
/// 修改手机号
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response UpdateMobile(dynamic _)
{
MobileVerify mobileVerify = this.GetReqData<MobileVerify>();
if (string.IsNullOrEmpty(mobileVerify.codeType))
{
return Fail("未指定短信类型。");
}
if (string.IsNullOrEmpty(mobileVerify.mobile))
{
return Fail("手机号不能为空。");
}
var code = redisCache.Read<string>("sendcodeinapp_" + mobileVerify.codeType + "_" + mobileVerify.mobile);
if (!string.IsNullOrEmpty(code) && code == mobileVerify.verifycode)
{
//return Success("验证成功。");
userIBLL.UpdateMobile(userInfo.userId, mobileVerify.mobile);
return Success("修改成功");
}
else
{
return Fail("验证失败,验证码错误或已失效。");
}
}
/// <summary>
/// 获取所有员工账号列表
@@ -509,6 +742,14 @@ namespace Learun.Application.WebApi
/// </summary>
public string deviceid { get; set; }
public string openid { get; set; }
/// <summary>
/// 发送短信类型:忘记密码forgetpwd,首次登录firstlogin,绑定微信bindwx,解绑微信unbindwx,修改手机号modifymobile,;
/// </summary>
public string codeType { get; set; }
/// <summary>
/// 短信验证码
/// </summary>
public string verifycode { get; set; }
}
/// <summary>
/// 修改密码
@@ -530,6 +771,10 @@ namespace Learun.Application.WebApi
{
public string mobile { get; set; }
public string verifycode { get; set; }
/// <summary>
/// 发送短信类型
/// </summary>
public string codeType { get; set; }
}




+ 53
- 29
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs Datei anzeigen

@@ -30,6 +30,7 @@ namespace Learun.Application.WebApi
public UsernologinApi()
: base("/learun/adms/usernologin")
{
Post["/logincodeverify"] = LoginCodeVerify;
Post["/sendcode"] = Sendcode;
Post["/forgetpass"] = forgetpass;

@@ -43,19 +44,27 @@ namespace Learun.Application.WebApi
private readonly ISms yixintongSms = new YixintongSms();
private ICache redisCache = CacheFactory.CaChe();
private Sys_UpdateRecordIBLL sysUpdateRecordIbll = new Sys_UpdateRecordBLL();
AnnexesFileIBLL annexesFileIbll=new AnnexesFileBLL();
AnnexesFileIBLL annexesFileIbll = new AnnexesFileBLL();



/// <summary>
/// 登录二次短信验证
/// 短信验证码校验
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response LoginCodeVerify(dynamic _)
{
MobileVerify mobileVerify = this.GetReqData<MobileVerify>();
var code = redisCache.Read<string>("studentuserlogin_" + mobileVerify.mobile);
if (string.IsNullOrEmpty(mobileVerify.codeType))
{
return Fail("未指定短信类型。");
}
if (string.IsNullOrEmpty(mobileVerify.mobile))
{
return Fail("手机号不能为空。");
}
var code = redisCache.Read<string>("sendcodeinapp_" + mobileVerify.codeType + "_" + mobileVerify.mobile);
if (!string.IsNullOrEmpty(code) && code == mobileVerify.verifycode)
{
return Success("验证成功。");
@@ -67,65 +76,80 @@ namespace Learun.Application.WebApi

}
/// <summary>
/// 忘记密码,发送验证码
/// 发送短信验证码
/// </summary>
/// <param name="_"></param>
/// <returns></returns>
private Response Sendcode(dynamic _)
{
LoginModel loginModel = this.GetReqData<LoginModel>();
UserEntity userEntity = userIBLL.GetEntityByMobile(loginModel.username);
if (string.IsNullOrEmpty(loginModel.codeType))
{
return Fail("未指定短信类型。");
}
UserEntity userEntity = null;
if (loginModel.codeType == "bindwx")
{
userEntity = userIBLL.GetEntityByAccount(loginModel.username);
}
else
{
userEntity = userIBLL.GetEntityByMobile(loginModel.username);
}
if (userEntity == null)
{
return Fail("用户不存在");
return Fail("用户不存在!");
}
#region 写入日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 1;
logEntity.F_OperateTypeId = ((int)OperationType.Login).ToString();
logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Login);
logEntity.F_OperateAccount = loginModel.username + "(" + userEntity.F_RealName + ")";
logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : loginModel.username;
logEntity.F_Module = Config.GetValue("SoftName");
logEntity.F_Description = "移动端";
#endregion

string raRndNum = Learun.Util.CommonHelper.RndNum(6);
if (string.IsNullOrEmpty(userEntity.F_Mobile))
{
return Fail("用户手机号不存在!");
}
if (loginModel.codeType == "firstlogin" && userEntity.F_HaveLogMark == true)
{
return Fail("当前用户非首次登录,请使用账号密码进行登录!");
}
//todo:待取消注释
//string raRndNum = Learun.Util.CommonHelper.RndNum(6);
string raRndNum = "123456";
var listStr = new List<string>();
var str1 = $"欢迎使用智慧校园,您本次登录的验证码是 " + raRndNum + "。";
listStr.Add(str1);
var result = yixintongSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr);
if (result.Result.code == "0")
//todo:待开发短信平台
//var result = yixintongSms.SendSmsToSingle(userEntity.F_Mobile, SmsType.LoginBind, listStr);
//if (result.Result.code == "0")
if (true)
{
redisCache.Write<string>("studentuserlogin_" + userEntity.F_Mobile, raRndNum, new TimeSpan(0, 5, 0));
redisCache.Write<string>("sendcodeinapp_" + loginModel.codeType + "_" + userEntity.F_Mobile, raRndNum, new TimeSpan(0, 5, 0));
//日志
logEntity = new LogEntity();
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 3;
logEntity.F_SourceObjectId = loginModel.codeType;
logEntity.F_OperateTypeId = "sms";
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 200;
logEntity.F_ExecuteResultJson = "短信发送成功:";// + result.Result.message;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile + " 验证码:" + raRndNum;
logEntity.WriteLog();
return Success("短信发送成功:");// + result.Result.message);
}
else
{
logEntity = new LogEntity();
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 4;
logEntity.F_SourceObjectId = loginModel.codeType;
logEntity.F_OperateTypeId = "sms";
logEntity.F_OperateType = "sms";
logEntity.F_OperateAccount = "system";
logEntity.F_ExecuteResult = 400;
logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
logEntity.F_Description = "短信发送:" + userEntity.F_Mobile;
logEntity.WriteLog();
return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
//logEntity.F_ExecuteResultJson = "短信发送失败:" + result.Result.message + result.Result.errorType;
//logEntity.F_Description = "短信发送:" + userEntity.F_Mobile;
//logEntity.WriteLog();
//return Fail("短信发送失败:" + result.Result.message + result.Result.errorType);
}
}
/// <summary>
/// 忘记密码修改密码
/// 忘记密码修改密码
/// </summary>
/// <param name="_"></param>
/// <returns></returns>


+ 85
- 55
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/WeixinApi.cs Datei anzeigen

@@ -18,6 +18,8 @@ using Learun.Util.Operat;
using Nancy.ModelBinding;
using Nancy.Responses;
using Newtonsoft.Json;
using Learun.Cache.Factory;
using Learun.Cache.Base;

namespace Learun.Application.WebApi.Modules
{
@@ -30,6 +32,7 @@ namespace Learun.Application.WebApi.Modules
private WeChatConfigIBLL weChatConfigIbll = new WeChatConfigBLL();
LR_Base_LogoIBLL baseLogoIbll = new LR_Base_LogoBLL();
CdMajorIBLL majorIbll = new CdMajorBLL();
private ICache redisCache = CacheFactory.CaChe();
public WeixinApi()
: base("/weixinapi")
{
@@ -183,71 +186,96 @@ namespace Learun.Application.WebApi.Modules
{
LoginModel loginModel = this.GetReqData<LoginModel>();

#region 内部账户验证
UserEntity userEntity = userIbll.CheckLogin(loginModel.username, loginModel.password);

#region 写入日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 1;
logEntity.F_OperateTypeId = ((int)OperationType.Login).ToString();
logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Login);
logEntity.F_OperateAccount = loginModel.username + "(" + userEntity.F_RealName + ")";
logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : loginModel.username;
logEntity.F_Module = Config.GetValue("SoftName");
logEntity.F_Description = "移动端";
#endregion

if (!userEntity.LoginOk)//登录失败
//短信验证码校验
if (string.IsNullOrEmpty(loginModel.codeType))
{
//写入日志
logEntity.F_ExecuteResult = 0;
logEntity.F_ExecuteResultJson = "登录失败:" + userEntity.LoginMsg;
logEntity.WriteLog();
return Fail(userEntity.LoginMsg);
return Fail("未指定短信类型。");
}
else
var mobiletemp = string.Empty;
if (loginModel.codeType == "bindwx")
{
ReqParameter req = this.Bind<ReqParameter>();
string token = OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_App", req.loginMark, false);//写入缓存信息
//写入日志
logEntity.F_ExecuteResult = 1;
logEntity.F_ExecuteResultJson = "登录成功";
logEntity.WriteLog();
OperatorResult res = OperatorHelper.Instance.IsOnLine(token, req.loginMark);
res.userInfo.password = null;
res.userInfo.secretkey = null;
var studententity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(userEntity.F_Account);
if (studententity != null)
{
res.userInfo.grade = studententity.Grade;
var majorinfo = majorIbll.GetCdMajorEntityByMajorNo(studententity.MajorNo);
if (majorinfo != null)
{
res.userInfo.majorno = majorinfo.ID ?? "";
}
mobiletemp = userIbll.GetEntityByAccount(loginModel.username)?.F_Mobile;
}
if (string.IsNullOrEmpty(mobiletemp))
{
return Fail("手机号不能为空。");
}
var code = redisCache.Read<string>("sendcodeinapp_" + loginModel.codeType + "_" + mobiletemp);
if (!string.IsNullOrEmpty(code) && code == loginModel.verifycode)
{
//return Success("验证成功。");
#region 内部账户验证
UserEntity userEntity = userIbll.CheckLogin(loginModel.username, loginModel.password);

}
//是否强密码验证
bool pwd = false;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["verifypwd"]) && ConfigurationManager.AppSettings["verifypwd"] == "true" && loginModel.up == false)
#region 写入日志
LogEntity logEntity = new LogEntity();
logEntity.F_CategoryId = 1;
logEntity.F_OperateTypeId = ((int)OperationType.Login).ToString();
logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Login);
logEntity.F_OperateAccount = loginModel.username + "(" + userEntity.F_RealName + ")";
logEntity.F_OperateUserId = !string.IsNullOrEmpty(userEntity.F_UserId) ? userEntity.F_UserId : loginModel.username;
logEntity.F_Module = Config.GetValue("SoftName");
logEntity.F_Description = "移动端";
#endregion

if (!userEntity.LoginOk)//登录失败
{
pwd = true;
//写入日志
logEntity.F_ExecuteResult = 0;
logEntity.F_ExecuteResultJson = "登录失败:" + userEntity.LoginMsg;
logEntity.WriteLog();
return Fail(userEntity.LoginMsg);
}
else
{
//保存用户设备号
userIbll.UpdateWeixinOpenId(userEntity.F_UserId, loginModel.openid);
//记录已登录标记
userIbll.UpdateHaveLogMark(userEntity.F_UserId);
ReqParameter req = this.Bind<ReqParameter>();
string token = OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_App", req.loginMark, false);//写入缓存信息
//写入日志
logEntity.F_ExecuteResult = 1;
logEntity.F_ExecuteResultJson = "登录成功";
logEntity.WriteLog();
OperatorResult res = OperatorHelper.Instance.IsOnLine(token, req.loginMark);
res.userInfo.password = null;
res.userInfo.secretkey = null;
var studententity = stuInfoBasicIBLL.GetStuInfoBasicEntityByStuNo(userEntity.F_Account);
if (studententity != null)
{
res.userInfo.grade = studententity.Grade;
var majorinfo = majorIbll.GetCdMajorEntityByMajorNo(studententity.MajorNo);
if (majorinfo != null)
{
res.userInfo.majorno = majorinfo.ID ?? "";
}

}
//是否强密码验证
bool pwd = false;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["verifypwd"]) && ConfigurationManager.AppSettings["verifypwd"] == "true" && loginModel.up == false)
{
pwd = true;
}
else
{
//保存用户设备号
userIbll.UpdateWeixinOpenId(userEntity.F_UserId, loginModel.openid);
}
var jsonData = new
{
baseinfo = res.userInfo,
post = postIBLL.GetListByPostIds(res.userInfo.postIds),
role = roleIBLL.GetListByRoleIds(res.userInfo.roleIds),
pwd = pwd
};
return Success(jsonData);
}
var jsonData = new
{
baseinfo = res.userInfo,
post = postIBLL.GetListByPostIds(res.userInfo.postIds),
role = roleIBLL.GetListByRoleIds(res.userInfo.roleIds),
pwd = pwd
};
return Success(jsonData);
#endregion
}
else
{
return Fail("验证失败,验证码错误或已失效。");
}
#endregion
}

private Response LoginByIdCard(dynamic _)
@@ -278,6 +306,8 @@ namespace Learun.Application.WebApi.Modules
}
else
{
//记录已登录标记
userIbll.UpdateHaveLogMark(userEntity.F_UserId);
ReqParameter req = this.Bind<ReqParameter>();
string token = OperatorHelper.Instance.AddLoginUser(userEntity.F_Account, "Learun_ADMS_6.1_App", req.loginMark, false);//写入缓存信息
//写入日志


+ 3
- 4
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/firstLogin.vue Datei anzeigen

@@ -3,9 +3,9 @@
<view class="content">
<!-- 标题文字 -->
<view class="main-title">
数字化智慧校园
首次登录
<!-- <text v-if="DEV" class="margin-left-sm text-red">(开发模式)</text> -->
<text class="text-gray margin-left-sm" style="font-size: 0.7em;">{{ APP_VERSION }}</text>
<!-- <text class="text-gray margin-left-sm" style="font-size: 0.7em;">{{ APP_VERSION }}</text> -->
</view>
<!-- 首页 Logo -->
@@ -28,7 +28,6 @@
</view>
<view class="btn" style="width: 100%;margin-top: 24px;margin-bottom: 8px;" @click="checkverifycode">登 录</view>
<view class="otherLogin">
<!-- 首次手机号登录 -->
<navigator url="/pages/login">常规登录</text></navigator>
</view>
</view>
@@ -121,7 +120,7 @@ export default{
if (success.pwd === true) {
this.SET_STORAGE('pwd', true);
this.TOAST("绑定失败!您的密码不满足强度要求,请您先修改密码后再执行系统其他操作");
this.TOAST("您的密码不满足强度要求,请您先修改密码后再执行系统其他操作");
}
setTimeout(()=>{
location.href = "http://" + window.location.host + "/#/pages/my/newpassword";


+ 1
- 1
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/wxLogin.vue Datei anzeigen

@@ -44,7 +44,7 @@
</view>
<l-button v-if="ready" @click="loginClick(null)" size="lg" color="blue" class="margin-top-sm block" block>确 认</l-button>
<view class="otherLogin">
<navigator url="/pages/login">常规登</text></navigator>
<navigator url="/pages/login">常规登</text></navigator>
</view>
<!-- <l-button v-if="enableSignUp" @click="signUp" size="lg" line="blue" class="margin-top-sm block" block>
教师注册


Laden…
Abbrechen
Speichern