Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
thomasDOTwtf
hub
Commits
ec3f9c59
Commit
ec3f9c59
authored
6 months ago
by
grollicus
Browse files
Options
Downloads
Patches
Plain Diff
audit log for logins
parent
c34eae39
Branches
feature/audit_log
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/views/auth.py
+8
-2
8 additions, 2 deletions
src/core/views/auth.py
with
8 additions
and
2 deletions
src/core/views/auth.py
+
8
−
2
View file @
ec3f9c59
...
@@ -40,10 +40,16 @@ class BaseLoginView(LoginView):
...
@@ -40,10 +40,16 @@ class BaseLoginView(LoginView):
def
get_form_kwargs
(
self
)
->
dict
[
str
,
Any
]:
def
get_form_kwargs
(
self
)
->
dict
[
str
,
Any
]:
return
{
'
with_theme_switcher
'
:
self
.
with_theme_switcher
,
**
super
().
get_form_kwargs
()}
return
{
'
with_theme_switcher
'
:
self
.
with_theme_switcher
,
**
super
().
get_form_kwargs
()}
def
form_valid
(
self
,
form
):
def
form_invalid
(
self
,
form
:
LoginForm
)
->
HttpResponse
:
logger
.
info
(
'
Invalid login attempt for username %s logged from %s
'
,
form
.
cleaned_data
.
get
(
"
username
"
),
self
.
request
.
META
.
get
(
'
REMOTE_ADDR
'
))
return
super
().
form_invalid
(
form
)
def
form_valid
(
self
,
form
:
LoginForm
):
user
=
form
.
get_user
()
user
=
form
.
get_user
()
self
.
request
.
session
[
'
theme
'
]
=
form
.
cleaned_data
.
get
(
'
theme
'
,
user
.
theme
)
self
.
request
.
session
[
'
theme
'
]
=
form
.
cleaned_data
.
get
(
'
theme
'
,
user
.
theme
)
return
super
().
form_valid
(
form
)
res
=
super
().
form_valid
(
form
)
logger
.
info
(
'
User %s logged in from %s
'
,
user
.
username
,
self
.
request
.
META
.
get
(
'
REMOTE_ADDR
'
))
return
res
class
BasePasswordResetView
(
PasswordResetView
):
class
BasePasswordResetView
(
PasswordResetView
):
...
...
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