Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDDD97-web-programming
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anton Hansson
TDDD97-web-programming
Commits
780ac0f4
Commit
780ac0f4
authored
3 years ago
by
Anton
Browse files
Options
Downloads
Patches
Plain Diff
add logout if auth fails
parent
c76b4c32
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lab4/twidder/database.db
+0
-0
0 additions, 0 deletions
lab4/twidder/database.db
lab4/twidder/server.py
+3
-3
3 additions, 3 deletions
lab4/twidder/server.py
lab4/twidder/static/client.js
+7
-6
7 additions, 6 deletions
lab4/twidder/static/client.js
with
10 additions
and
9 deletions
lab4/twidder/database.db
+
0
−
0
View file @
780ac0f4
No preview for this file type
This diff is collapsed.
Click to expand it.
lab4/twidder/server.py
+
3
−
3
View file @
780ac0f4
...
...
@@ -279,7 +279,7 @@ def get_user_messages_by_token():
success
=
True
,
message
=
"
Messages retrieved
"
,
data
=
formatted_messages
)
else
:
return
create_response
(
success
=
False
,
message
=
"
You are not signed in
"
)
return
create_response
(
success
=
False
,
message
=
"
Authentication failed
"
)
@app.route
(
"
/get-user-messages-by-email
"
,
methods
=
[
"
GET
"
])
...
...
@@ -303,7 +303,7 @@ def get_user_messages_by_email():
else
:
return
create_response
(
success
=
False
,
message
=
"
Recipient does no exist
"
)
else
:
return
create_response
(
success
=
False
,
message
=
"
You are not signed in
"
)
return
create_response
(
success
=
False
,
message
=
"
Authentication failed
"
)
@app.route
(
"
/post-message
"
,
methods
=
[
"
POST
"
])
...
...
@@ -328,7 +328,7 @@ def post_message():
)
return
create_response
(
success
=
True
,
message
=
"
Message sent
"
)
else
:
return
create_response
(
success
=
False
,
message
=
"
You are not signed in
"
)
return
create_response
(
success
=
False
,
message
=
"
Authentication failed
"
)
def
ws_broadcast_nr_active_user_changed
():
...
...
This diff is collapsed.
Click to expand it.
lab4/twidder/static/client.js
+
7
−
6
View file @
780ac0f4
...
...
@@ -394,12 +394,7 @@ function signOut() {
window
.
localStorage
.
removeItem
(
"
token
"
);
window
.
localStorage
.
removeItem
(
"
email
"
);
displayView
();
}
else
{
window
.
localStorage
.
removeItem
(
"
token
"
);
window
.
localStorage
.
removeItem
(
"
email
"
);
showModal
(
"
Token not valid. You have been logged out
"
);
displayView
();
}
}
};
user_identifier
=
localStorage
.
getItem
(
"
email
"
);
...
...
@@ -451,6 +446,12 @@ function xmlRequest(url, callback, params, token = null, requestType) {
xhttp
.
onreadystatechange
=
function
()
{
if
(
this
.
readyState
==
4
&&
this
.
status
==
200
)
{
callback
(
JSON
.
parse
(
xhttp
.
responseText
));
if
(
JSON
.
parse
(
xhttp
.
responseText
).
message
===
"
Authentication failed
"
)
{
window
.
localStorage
.
removeItem
(
"
token
"
);
window
.
localStorage
.
removeItem
(
"
email
"
);
displayView
();
showModal
(
"
Authentication failed. You must sign in again
"
)
}
}
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment