Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
905acc38
Commit
905acc38
authored
Sep 22, 2021
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
eebb84bd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
2 deletions
+52
-2
AppletLoginController.cs
Mall.WebApi/Controllers/User/AppletLoginController.cs
+52
-2
No files found.
Mall.WebApi/Controllers/User/AppletLoginController.cs
View file @
905acc38
...
@@ -57,12 +57,14 @@ namespace Mall.WebApi.Controllers.User
...
@@ -57,12 +57,14 @@ namespace Mall.WebApi.Controllers.User
[
RateValve
(
Policy
=
Policy
.
Ip
,
Limit
=
10
,
Duration
=
60
)]
[
RateValve
(
Policy
=
Policy
.
Ip
,
Limit
=
10
,
Duration
=
60
)]
public
ApiResult
Login
(
object
requestMsg
)
public
ApiResult
Login
(
object
requestMsg
)
{
{
var
lObj
=
JObject
.
Parse
(
requestMsg
.
ToString
());
var
lObj
=
JObject
.
Parse
(
requestMsg
.
ToString
());
var
requestParm
=
new
RequestParm
()
var
requestParm
=
new
RequestParm
()
{
{
TenantId
=
lObj
.
GetInt
(
"TenantId"
),
TenantId
=
lObj
.
GetInt
(
"TenantId"
),
MallBaseId
=
lObj
.
GetInt
(
"MallBaseId"
),
MallBaseId
=
lObj
.
GetInt
(
"MallBaseId"
),
msg
=
lObj
.
GetStringValue
(
"msg"
)
token
=
lObj
.
GetStringValue
(
"token"
),
msg
=
lObj
.
GetStringValue
(
"msg"
)
};
};
JObject
parms
=
JObject
.
Parse
(
requestParm
.
msg
.
ToString
());
JObject
parms
=
JObject
.
Parse
(
requestParm
.
msg
.
ToString
());
RB_Member_User_Extend
demodel
=
new
RB_Member_User_Extend
()
RB_Member_User_Extend
demodel
=
new
RB_Member_User_Extend
()
...
@@ -97,6 +99,7 @@ namespace Mall.WebApi.Controllers.User
...
@@ -97,6 +99,7 @@ namespace Mall.WebApi.Controllers.User
return
ApiResult
.
ParamIsNull
(
"请传递唯一码"
);
return
ApiResult
.
ParamIsNull
(
"请传递唯一码"
);
}
}
int
LoginUserId
=
0
;
var
opcache
=
UserReidsCache
.
GetMiniAppUsetOpenId
(
demodel
.
OpenId
);
var
opcache
=
UserReidsCache
.
GetMiniAppUsetOpenId
(
demodel
.
OpenId
);
if
(
opcache
!=
null
&&
!
string
.
IsNullOrEmpty
(
opcache
.
UserOpenId
))
if
(
opcache
!=
null
&&
!
string
.
IsNullOrEmpty
(
opcache
.
UserOpenId
))
{
{
...
@@ -104,7 +107,22 @@ namespace Mall.WebApi.Controllers.User
...
@@ -104,7 +107,22 @@ namespace Mall.WebApi.Controllers.User
demodel
.
OpenId
=
opcache
.
UserOpenId
;
demodel
.
OpenId
=
opcache
.
UserOpenId
;
}
}
else
{
else
{
return
ApiResult
.
ParamIsNull
(
"未获取到唯一码,请刷新后再试"
);
if
(
string
.
IsNullOrEmpty
(
requestParm
.
token
))
{
return
ApiResult
.
ParamIsNull
(
"请传递唯一码"
);
}
else
{
LoginUserId
=
JWTValidatGetUserId
(
requestParm
.
token
);
if
(
LoginUserId
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请传递唯一码"
);
}
var
loginModel
=
UserReidsCache
.
GetAppletUserLoginInfo
(
LoginUserId
);
demodel
.
OpenId
=
loginModel
?.
OpenId
??
""
;
if
(
string
.
IsNullOrEmpty
(
demodel
.
OpenId
))
{
return
ApiResult
.
ParamIsNull
(
"请传递唯一码"
);
}
}
}
}
Model
.
Extend
.
MarketingCenter
.
RB_DiscountCoupon_Extend
couponResult
=
new
Model
.
Extend
.
MarketingCenter
.
RB_DiscountCoupon_Extend
();
Model
.
Extend
.
MarketingCenter
.
RB_DiscountCoupon_Extend
couponResult
=
new
Model
.
Extend
.
MarketingCenter
.
RB_DiscountCoupon_Extend
();
...
@@ -463,7 +481,39 @@ namespace Mall.WebApi.Controllers.User
...
@@ -463,7 +481,39 @@ namespace Mall.WebApi.Controllers.User
/// <summary>
/// token校验
/// </summary>
/// <param name="actionContext"></param>
/// <param name="token"></param>
private
int
JWTValidatGetUserId
(
string
token
)
{
int
UserID
=
0
;
if
(!
string
.
IsNullOrEmpty
(
token
))
{
//解析token,校验是否失效
try
{
IJsonSerializer
serializer
=
new
JsonNetSerializer
();
IDateTimeProvider
provider
=
new
UtcDateTimeProvider
();
IJwtValidator
validator
=
new
JwtValidator
(
serializer
,
provider
);
IBase64UrlEncoder
urlEncoder
=
new
JwtBase64UrlEncoder
();
IJwtDecoder
decoder
=
new
JwtDecoder
(
serializer
,
validator
,
urlEncoder
);
string
secret
=
Config
.
JwtSecretKey
;
var
json
=
decoder
.
Decode
(
token
,
secret
,
verify
:
true
);
//token为之前生成的字符串
JObject
jwtJson
=
JObject
.
Parse
(
json
);
string
userInfo
=
jwtJson
[
"mall_userInfo"
].
ToString
();
JObject
parms
=
JObject
.
Parse
(
userInfo
);
UserID
=
parms
.
GetInt
(
"uid"
,
0
);
}
catch
(
Exception
)
{
}
}
return
UserID
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment