Browse Source

Remember Me API

Dev
Janie 2 years ago
parent
commit
662704ef73
  1. 2
      EuroTran/EasyBL.WEBAPP/ShowEasy/SignupService.cs
  2. 55
      EuroTran/EasyBL.WEBAPP/ShowEasy/SystemService.cs
  3. 12
      EuroTran/WebApp/Controllers/SystemController.cs

2
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);

55
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<OTB_SYS_TicketAuth>().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<OTB_SYS_TicketAuth>()
.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
}
}

12
EuroTran/WebApp/Controllers/SystemController.cs

@ -40,5 +40,17 @@ namespace WebApp.Controllers
//登陸並返回token
return new SystemService().Login(dto);
}
/// <summary>
/// 記住密碼
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
[HttpGet]
public HttpResponseMessage RememberMe(string Account)
{
//登陸並返回token
return new SystemService().RememberMe(Account);
}
}
}
Loading…
Cancel
Save