Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mr-julyedu
Overview
Overview
Details
Activity
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
baiguangyao
mr-julyedu
Commits
06760006
Commit
06760006
authored
Jun 10, 2019
by
zhanghaozhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cookie失效跳转登录
parent
f8861e99
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
8 deletions
+23
-8
src/App.js
+14
-4
src/components/passport/index.js
+8
-3
src/router/privateRoute.js
+1
-1
No files found.
src/App.js
View file @
06760006
...
...
@@ -26,7 +26,14 @@ class App extends Component {
cookie
.
set
(
'plat'
,
'5'
)
http
.
get
(
`
${
api
.
home
}
/m/user_info`
).
then
(
res
=>
{
this
.
props
.
setCurrentUser
(
this
.
storeUser
(
res
))
if
(
res
.
data
.
code
===
4040
)
{
if
(
!
location
.
pathname
.
includes
(
'/passport'
))
{
location
.
assign
(
'/passport'
)
}
}
else
{
this
.
props
.
setCurrentUser
(
this
.
storeUser
(
res
))
}
})
}
...
...
@@ -38,7 +45,8 @@ class App extends Component {
avatar_file
:
avatar
,
user_name
:
username
,
is_vip
:
isVIP
,
uid
uid
,
code
}
}
=
res
.
data
...
...
@@ -49,13 +57,15 @@ class App extends Component {
username
,
isVIP
,
avatar
,
uid
uid
,
code
}
}
}
else
{
payload
=
{
hasError
:
true
,
msg
:
res
.
data
.
msg
msg
:
res
.
data
.
msg
,
code
:
res
.
data
.
code
}
}
return
payload
...
...
src/components/passport/index.js
View file @
06760006
import
React
,
{
Component
}
from
'react'
import
{
Route
,
Switch
}
from
'react-router-dom'
import
{
Route
,
Switch
,
Redirect
}
from
'react-router-dom'
import
'./passport.scss'
import
{
WithFullSize
}
from
'@/HOCs'
import
{
WithFullSize
}
from
'@/HOCs'
import
WechatLogin
from
'./wechatLogin'
import
AccountLogin
from
'./accountLogin'
import
ForgotPassword
from
'./forgotPassword'
...
...
@@ -42,10 +42,15 @@ class Passport extends Component {
}
render
()
{
let
{
match
}
=
this
.
props
let
{
match
,
location
}
=
this
.
props
console
.
log
(
location
)
return
(
<
div
className
=
"passport"
>
<
Switch
>
<
Redirect
exact
from
=
{
'/passport'
}
to
=
{{...
location
,
...{
pathname
:
'/passport/account-login'
}}}
/
>
<
Route
path
=
{
match
.
url
+
'/wechat-login'
}
render
=
{()
=>
<
WechatLogin
loginWays
=
{
this
.
state
.
loginWays
}
/>}/
>
<
Route
path
=
{
match
.
url
+
'/account-login'
}
component
=
{
AccountLogin
}
/
>
...
...
src/router/privateRoute.js
View file @
06760006
...
...
@@ -11,7 +11,7 @@ const PrivateRoute = ({component: Component, path, user, ...rest}) => {
return
authenticated
?
<
Component
{...
props
}
/
>
:
<
Redirect
to
=
{{
pathname
:
'/passport
/account-login
'
,
pathname
:
'/passport'
,
state
:
{
from
:
props
.
location
}
}}
/
>
}}
/
>
...
...
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