Commit c7ed021 1 parent f1db34b commit c7ed021 Copy full SHA for c7ed021
File tree 3 files changed +10
-28
lines changed
3 files changed +10
-28
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ def login (request) :
145
145
if hash_code (password ) != user [0 ].password :
146
146
return JsonResponse ({'result' : 200 , 'msg' : 'wrong password' })
147
147
else :
148
- return JsonResponse ({'result' : 200 , 'msg' : 'success' })
148
+ username = user [0 ].username
149
+ return JsonResponse ({'result' : 200 , 'msg' : 'success' , 'username' : username })
149
150
150
151
Original file line number Diff line number Diff line change @@ -9,8 +9,9 @@ export default new Vuex.Store({
9
9
username : ''
10
10
} ,
11
11
mutations : {
12
- increment ( state ) {
13
- state . count ++
12
+ setUserStatus ( state , user ) {
13
+ state . isLogin = true ;
14
+ state . username = user ;
14
15
}
15
16
} ,
16
17
actions : {
Original file line number Diff line number Diff line change @@ -58,25 +58,6 @@ export default {
58
58
}
59
59
},
60
60
methods: {
61
- log_in (formName ) {
62
- if (formName .name == ' ' || formName .pwd == ' ' ) {
63
- this .$message ({
64
- message: " email and password can not be empty" ,
65
- type: " error"
66
- })
67
- }
68
- else {
69
- if (formName .name == ' 358746595@qq.com' && formName .pwd == ' hedyfattoo' ) {
70
- this .$router .push (' /upload' )
71
- }
72
- else {
73
- this .$message ({
74
- message: " wrong email or password" ,
75
- type: " error"
76
- })
77
- }
78
- }
79
- },
80
61
to_home () {
81
62
this .$router .push (' /' )
82
63
},
@@ -88,15 +69,14 @@ export default {
88
69
let url = " https://fangzx.pythonanywhere.com/api/login" ;
89
70
let json_data = {
90
71
email: this .ruleForm .name ,
91
- password: this .ruleForm .password
72
+ password: this .ruleForm .pwd
92
73
}
93
74
axios .post (url, json_data, config).then (response => {
94
75
if (response .data .msg == " success" ) {
95
- this .$msgbox ({
96
- title: ' success' ,
97
- message: " sign up successfully"
98
- })
99
- this .$router .push (' /login' )
76
+ sessionStorage .setItem (" username" , response .data .username );
77
+ this .$store .commit (" setUserStatus" , response .data .username );
78
+ console .log (this .$store .state .username );
79
+ this .$router .push (' /' );
100
80
}
101
81
else {
102
82
this .$msgbox ({
You can’t perform that action at this time.
0 commit comments