diff --git a/EuroTran/EasyBL.WEBAPP/EasyBL.WEBAPP.csproj b/EuroTran/EasyBL.WEBAPP/EasyBL.WEBAPP.csproj
index e4725e5..a68ce57 100644
--- a/EuroTran/EasyBL.WEBAPP/EasyBL.WEBAPP.csproj
+++ b/EuroTran/EasyBL.WEBAPP/EasyBL.WEBAPP.csproj
@@ -81,6 +81,7 @@
+
diff --git a/EuroTran/EasyBL.WEBAPP/SETokenUtil.cs b/EuroTran/EasyBL.WEBAPP/SETokenUtil.cs
new file mode 100644
index 0000000..e5de755
--- /dev/null
+++ b/EuroTran/EasyBL.WEBAPP/SETokenUtil.cs
@@ -0,0 +1,54 @@
+using Entity;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EasyBL.WEBAPP
+{
+ public static class SETokenUtil
+ {
+
+ public static SEToken GetToken(HttpRequestMessage message) {
+
+ SEToken seToken = new SEToken();
+
+ IEnumerable headerValues;
+ if (message.Headers.TryGetValues("authtoken", out headerValues))
+ {
+ var token = headerValues.FirstOrDefault();
+
+ seToken = Decrypt(token);
+
+ }
+
+ return seToken;
+
+ }
+
+ public static SEToken Decrypt(string data) {
+
+ SEToken seToken = new SEToken();
+
+ if (!string.IsNullOrEmpty(data)) {
+
+ var authtoken = EasyNet.SecurityUtil.Decrypt(data);
+ var saAuthtoken = authtoken.Split(',');
+
+ seToken.OrgID = saAuthtoken[0].Split(':')[1];
+ seToken.Email = saAuthtoken[1].Split(':')[1];
+ seToken.MemberID = saAuthtoken[1].Split(':')[1];
+ seToken.SignToken = saAuthtoken[2].Split(':')[1];
+
+ }
+
+ return seToken;
+ }
+
+
+
+
+ }
+}
diff --git a/EuroTran/Entity/Entity.csproj b/EuroTran/Entity/Entity.csproj
index 7b4afeb..74dd0d0 100644
--- a/EuroTran/Entity/Entity.csproj
+++ b/EuroTran/Entity/Entity.csproj
@@ -187,6 +187,7 @@
True
True
+
diff --git a/EuroTran/Entity/SEToken.cs b/EuroTran/Entity/SEToken.cs
new file mode 100644
index 0000000..f01a8a5
--- /dev/null
+++ b/EuroTran/Entity/SEToken.cs
@@ -0,0 +1,32 @@
+using System;
+
+namespace Entity
+{
+ public class SEToken
+ {
+ ///
+ /// 組織ID
+ ///
+ public string OrgID { get; set; }
+
+ ///
+ /// 用户ID
+ ///
+ public string MemberID { get; set; }
+
+ ///
+ /// 用户Email
+ ///
+ public string Email { get; set; }
+
+ ///
+ /// 用户名对应签名Token
+ ///
+ public string SignToken { get; set; }
+
+ ///
+ /// Token过期时间
+ ///
+ public DateTime ExpireTime { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/EuroTran/WebApp/Controllers/FavoriteController.cs b/EuroTran/WebApp/Controllers/FavoriteController.cs
index e03df2d..2339b42 100644
--- a/EuroTran/WebApp/Controllers/FavoriteController.cs
+++ b/EuroTran/WebApp/Controllers/FavoriteController.cs
@@ -2,7 +2,9 @@
using EasyBL.WebApi.Common;
using EasyBL.WebApi.Filters;
using EasyBL.WebApi.Message;
+using EasyBL.WEBAPP;
using EasyBL.WEBAPP.SYS;
+using EasyNet;
using Entity.ShowEasyDtos;
using Entity.Sugar;
using Newtonsoft.Json;
@@ -22,27 +24,40 @@ namespace WebApp.Controllers
[SEApiSecurityFilter]
public HttpResponseMessage Favorite([FromBody] FavoriteDTO favorite)
{
+
+ // get authtoken
+ var SEToken = SETokenUtil.GetToken(this.Request);
+ favorite.MemberID = SEToken.Email;
+
return new FavoriteService().SaveFavorite(favorite);
}
[HttpGet]
[SEApiSecurityFilter]
- public HttpResponseMessage Favorites(string MemberID)
+ public HttpResponseMessage Favorites()
{
+ // get authtoken
+ var SEToken = SETokenUtil.GetToken(this.Request);
+
+ // get MemberID from authtoken
+
FavoriteDTO favorite = new FavoriteDTO();
- favorite.MemberID = MemberID;
+ favorite.MemberID = SEToken.Email;
return new FavoriteService().GetFavorites(favorite);
}
[HttpGet]
[SEApiSecurityFilter]
- public HttpResponseMessage Favorites(string MemberID, string Type)
+ public HttpResponseMessage Favorites(string Type)
{
+ // get authtoken
+ var SEToken = SETokenUtil.GetToken(this.Request);
+
FavoriteDTO favorite = new FavoriteDTO();
- favorite.MemberID = MemberID;
+ favorite.MemberID = SEToken.Email;
favorite.Type = Type;
return new FavoriteService().GetFavorites(favorite);