From 662704ef73486f34347bb4d1c8ebf484f2185921 Mon Sep 17 00:00:00 2001 From: Janie <109517022+Janie06@users.noreply.github.com> Date: Fri, 10 Mar 2023 13:47:02 +0800 Subject: [PATCH] Remember Me API --- .../EasyBL.WEBAPP/ShowEasy/SignupService.cs | 2 + .../EasyBL.WEBAPP/ShowEasy/SystemService.cs | 55 ++++++++++++++++++- .../WebApp/Controllers/SystemController.cs | 12 ++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/EuroTran/EasyBL.WEBAPP/ShowEasy/SignupService.cs b/EuroTran/EasyBL.WEBAPP/ShowEasy/SignupService.cs index 96cb1a5..24fb7d8 100644 --- a/EuroTran/EasyBL.WEBAPP/ShowEasy/SignupService.cs +++ b/EuroTran/EasyBL.WEBAPP/ShowEasy/SignupService.cs @@ -85,6 +85,8 @@ namespace EasyBL.WEBAPP.SYS Type = "to" }; toEmail.Add(oEmailTo); + oEmail.FromUserName = " ShowEasy 簡單平台股份有限公司"; + oEmail.FromEmail = "No-Reply@showeasy.com"; oEmail.FromUserName = "【ShowEasy 會員認證】"; //取fonfig oEmail.Title = "感謝您註冊ShowEasy"; //取fonfig oEmail.EmailBody = VerifyAccount_Mail(newUser.OrgID, newUser.MemberID, newUser.FirstName); diff --git a/EuroTran/EasyBL.WEBAPP/ShowEasy/SystemService.cs b/EuroTran/EasyBL.WEBAPP/ShowEasy/SystemService.cs index 5a67f8b..96d25a4 100644 --- a/EuroTran/EasyBL.WEBAPP/ShowEasy/SystemService.cs +++ b/EuroTran/EasyBL.WEBAPP/ShowEasy/SystemService.cs @@ -17,6 +17,7 @@ using System.Web; namespace EasyBL.WEBAPP.SYS { + public class SystemService : ServiceBase { @@ -162,7 +163,7 @@ namespace EasyBL.WEBAPP.SYS // LoginIp = i_crm.ClientIP, LoginTime = DateTime.Now }; - var iExpireTime = 240; + var iExpireTime = 43200; var sExpireTime = Common.GetSystemSetting(db, oUser.OrgID, @"ExpireTime"); if (!string.IsNullOrEmpty(sExpireTime)) { @@ -172,7 +173,7 @@ namespace EasyBL.WEBAPP.SYS { iExpireTime = int.Parse(Common.GetAppSettings(@"ExpireTime")); } - ticket.ExpireTime = DateTime.Now.AddMinutes(iExpireTime); //30分钟过期 + ticket.ExpireTime = DateTime.Now.AddMinutes(iExpireTime); //30天過期 ticket.IsVerify = @"Y"; var oTicket = db.Queryable().Single(x => x.OrgID == oUser.OrgID && x.UserID == oUser.Account); if (oTicket != null) @@ -211,6 +212,7 @@ namespace EasyBL.WEBAPP.SYS catch (Exception ex) { sError = Util.GetLastExceptionMsg(ex); + System.Diagnostics.Debug.WriteLine(sError); } finally { @@ -228,5 +230,54 @@ namespace EasyBL.WEBAPP.SYS } #endregion + #region RememberMe + public HttpResponseMessage RememberMe(string Account) + { + SuccessResponseMessage srm = null; + string sError = null; + var db = SugarBase.GetIntance(); + int errorStaus = 500; + try + { + do + { + var UserLogin = db.Queryable() + .Where(x => x.UserID == Account) + .Single(); + + if (UserLogin == null) + { + sError = @"帳號或密碼不正確"; //帳號或密碼不正確 + errorStaus = (int)StatusCodeEnum.Unauthorized; + break; + } + + srm = new SuccessResponseMessage(null, null); + srm.DATA.Add("authtoken", UserLogin); + } while (false); + } + catch (Exception ex) + { + sError = Util.GetLastExceptionMsg(ex); + System.Diagnostics.Debug.WriteLine(sError); + } + finally + { + if (null != sError) + { + srm = new SuccessResponseMessage(null, null) + { + STATUSCODE = errorStaus, + MSG = sError + }; + } + } + + return HttpResponseExtension.ToJson(JsonConvert.SerializeObject(srm)); + } + #endregion RememberMe + + + } } \ No newline at end of file diff --git a/EuroTran/WebApp/Controllers/SystemController.cs b/EuroTran/WebApp/Controllers/SystemController.cs index e467904..bbef2b1 100644 --- a/EuroTran/WebApp/Controllers/SystemController.cs +++ b/EuroTran/WebApp/Controllers/SystemController.cs @@ -40,5 +40,17 @@ namespace WebApp.Controllers //登陸並返回token return new SystemService().Login(dto); } + + /// + /// 記住密碼 + /// + /// + /// + [HttpGet] + public HttpResponseMessage RememberMe(string Account) + { + //登陸並返回token + return new SystemService().RememberMe(Account); + } } }