Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
79e798ab
Commit
79e798ab
authored
8 years ago
by
Jacek Lebioda
Browse files
Options
Downloads
Patches
Plain Diff
Logging in and out works
parent
a7337c24
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
smash/web/auth.py
+17
-0
17 additions, 0 deletions
smash/web/auth.py
smash/web/templates/login.html
+7
-1
7 additions, 1 deletion
smash/web/templates/login.html
smash/web/views.py
+7
-5
7 additions, 5 deletions
smash/web/views.py
with
31 additions
and
6 deletions
smash/web/auth.py
0 → 100644
+
17
−
0
View file @
79e798ab
from
django.contrib.auth
import
authenticate
,
login
,
logout
def
do_login
(
request
):
user
=
authenticate
(
username
=
request
.
POST
.
get
(
'
username
'
,
'
none
'
),
password
=
request
.
POST
.
get
(
'
password
'
,
'
none
'
))
if
user
is
not
None
:
login
(
request
,
user
)
return
True
,
"
ok
"
return
False
,
"
login_failed
"
def
do_logout
(
request
):
if
request
.
user
.
is_authenticated
:
logout
(
request
)
return
True
,
"
logout
"
return
False
,
"
logout_failed
"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
smash/web/templates/login.html
+
7
−
1
View file @
79e798ab
...
...
@@ -55,6 +55,12 @@
<p>
You have logged out of the Scheduling System
</p>
</div>
{% elif state == "logout_failed" %}
<div
class=
"callout callout-danger"
>
<h4>
Error!
</h4>
<p>
You cannot log out, if you are not logged in!
</p>
</div>
{% elif state == "login_failed" %}
<div
class=
"callout callout-danger"
>
<h4>
Error!
</h4>
...
...
@@ -71,7 +77,7 @@
{% csrf_token %}
<div
class=
"form-group has-feedback"
>
<input
type=
"
email
"
name=
"username"
class=
"form-control"
placeholder=
"E-mail"
>
<input
type=
"
text
"
name=
"username"
class=
"form-control"
placeholder=
"E-mail"
>
<span
class=
"glyphicon glyphicon-envelope form-control-feedback"
></span>
</div>
<div
class=
"form-group has-feedback"
>
...
...
This diff is collapsed.
Click to expand it.
smash/web/views.py
+
7
−
5
View file @
79e798ab
...
...
@@ -4,9 +4,9 @@ from django.template import loader
from
django.views
import
generic
from
.models
import
*
from
.forms
import
*
from
.auth
import
*
# Own wrapper for django logging in/out
from
django.forms
import
modelformset_factory
from
django.shortcuts
import
render
# import auth
# Create your views here.
def
index
(
request
):
...
...
@@ -23,8 +23,8 @@ def login(request):
context
[
'
state
'
]
=
request
.
GET
.
get
(
'
error
'
)
if
request
.
method
==
"
POST
"
and
request
.
POST
:
state
=
auth
.
do_login
(
request
)
if
state
==
True
:
state
=
do_login
(
request
)
if
state
[
0
]
==
True
:
return
redirect
(
assignments
)
else
:
return
redirect
(
'
/login?error=
'
+
state
[
1
])
...
...
@@ -33,8 +33,10 @@ def login(request):
def
logout
(
request
):
state
=
auth
.
do_logout
(
request
)
return
render
(
request
,
"
login.html
"
,
{
'
state
'
:
state
})
state
=
do_logout
(
request
)
print
state
return
redirect
(
'
/login?error=
'
+
state
[
1
])
def
assignments
(
request
):
...
...
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