Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
ac4b954c
Commit
ac4b954c
authored
Jul 19, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename authentication activity observer methods
parent
41607661
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
15 deletions
+11
-15
config/initializers/warden.rb
config/initializers/warden.rb
+2
-2
lib/gitlab/auth/activity.rb
lib/gitlab/auth/activity.rb
+3
-13
spec/features/users/login_spec.rb
spec/features/users/login_spec.rb
+1
-0
spec/support/prometheus/custom_matchers.rb
spec/support/prometheus/custom_matchers.rb
+5
-0
No files found.
config/initializers/warden.rb
View file @
ac4b954c
...
...
@@ -22,12 +22,12 @@ Rails.application.configure do |config|
end
Warden
::
Manager
.
after_set_user
(
scope: :user
,
only: :set_user
)
do
|
user
,
auth
,
opts
|
Gitlab
::
Auth
::
Activity
.
new
(
opts
).
user_se
t_manually
!
Gitlab
::
Auth
::
Activity
.
new
(
opts
).
user_se
ssion_override
!
end
Warden
::
Manager
.
before_logout
(
scope: :user
)
do
|
user
,
auth
,
opts
|
ActiveSession
.
destroy
(
user
||
auth
.
user
,
auth
.
request
.
session
.
id
)
Gitlab
::
Auth
::
Activity
.
new
(
opts
).
user_
log
out!
Gitlab
::
Auth
::
Activity
.
new
(
opts
).
user_
signed_
out!
end
end
lib/gitlab/auth/activity.rb
View file @
ac4b954c
...
...
@@ -39,28 +39,18 @@ module Gitlab
self
.
class
.
user_session_fetched_counter
.
increment
end
def
user_se
t_manually
!
def
user_se
ssion_override
!
self
.
class
.
user_session_override_counter
.
increment
end
def
user_
log
out!
def
user_
signed_
out!
self
.
class
.
user_signed_out_counter
.
increment
end
class
StubCounter
def
initialize
(
metric
)
Rails
.
logger
.
warn
(
"METRIC
#{
metric
}
"
)
end
def
increment
end
end
COUNTERS
.
each_pair
do
|
metric
,
description
|
define_singleton_method
(
"
#{
metric
}
_counter"
)
do
strong_memoize
(
metric
)
do
StubCounter
.
new
(
metric
)
# Gitlab::Metrics.counter("gitlab_auth_#{metric}_total", description)
Gitlab
::
Metrics
.
counter
(
"gitlab_auth_
#{
metric
}
_total"
.
to_sym
,
description
)
end
end
end
...
...
spec/features/users/login_spec.rb
View file @
ac4b954c
...
...
@@ -29,6 +29,7 @@ describe 'Login' do
User
.
delete_all
user
=
create
(
:admin
,
password_automatically_set:
true
)
expect
(
Gitlab
::
Auth
::
Activity
).
to
increment
(
:user_authenticated_counter
)
visit
root_path
expect
(
current_path
).
to
eq
edit_user_password_path
...
...
spec/support/prometheus/custom_matchers.rb
0 → 100644
View file @
ac4b954c
RSpec
::
Matchers
.
define
:increment
do
|
counter
|
match
do
|
metric
|
expect
(
metric
.
send
(
counter
)).
to
receive
(
:increment
)
end
end
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