Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
open-source
MetaGer
Commits
dc787fd2
Commit
dc787fd2
authored
4 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Patches
Plain Diff
Added Prometheus statistic for captcha
parent
515c89c5
No related branches found
Branches containing commit
No related tags found
2 merge requests
!1574
Development
,
!1573
Resolve "New Captcha Texts"
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/Http/Controllers/HumanVerification.php
+4
-3
4 additions, 3 deletions
app/Http/Controllers/HumanVerification.php
app/Http/Middleware/HumanVerification.php
+1
-0
1 addition, 0 deletions
app/Http/Middleware/HumanVerification.php
app/PrometheusExporter.php
+25
-0
25 additions, 0 deletions
app/PrometheusExporter.php
with
30 additions
and
3 deletions
app/Http/Controllers/HumanVerification.php
+
4
−
3
View file @
dc787fd2
...
...
@@ -33,7 +33,7 @@ class HumanVerification extends Controller
}
if
(
$request
->
getMethod
()
==
'POST'
)
{
\App\PrometheusExporter
::
CaptchaAnswered
();
$lockedKey
=
$user
[
"lockedKey"
];
$key
=
$request
->
input
(
'captcha'
);
$key
=
strtolower
(
$key
);
...
...
@@ -42,7 +42,7 @@ class HumanVerification extends Controller
$captcha
=
Captcha
::
create
(
"default"
,
true
);
$user
[
"lockedKey"
]
=
$captcha
[
"key"
];
HumanVerification
::
saveUser
(
$user
);
\App\PrometheusExporter
::
CaptchaShown
();
return
view
(
'humanverification.captcha'
)
->
with
(
'title'
,
'Bestätigung notwendig'
)
->
with
(
'uid'
,
$user
[
"uid"
])
->
with
(
'id'
,
$id
)
...
...
@@ -50,6 +50,7 @@ class HumanVerification extends Controller
->
with
(
'image'
,
$captcha
[
"img"
])
->
with
(
'errorMessage'
,
'Fehler: Falsche Eingabe!'
);
}
else
{
\App\PrometheusExporter
::
CaptchaCorrect
();
# If we can unlock the Account of this user we will redirect him to the result page
if
(
$user
!==
null
&&
$user
[
"locked"
])
{
# The Captcha was correct. We can remove the key from the user
...
...
@@ -67,7 +68,7 @@ class HumanVerification extends Controller
$captcha
=
Captcha
::
create
(
"default"
,
true
);
$user
[
"lockedKey"
]
=
$captcha
[
"key"
];
HumanVerification
::
saveUser
(
$user
);
\App\PrometheusExporter
::
CaptchaShown
();
return
view
(
'humanverification.captcha'
)
->
with
(
'title'
,
'Bestätigung notwendig'
)
->
with
(
'uid'
,
$user
[
"uid"
])
->
with
(
'id'
,
$id
)
...
...
This diff is collapsed.
Click to expand it.
app/Http/Middleware/HumanVerification.php
+
1
−
0
View file @
dc787fd2
...
...
@@ -102,6 +102,7 @@ class HumanVerification
if
(
$user
[
"locked"
])
{
$captcha
=
Captcha
::
create
(
"default"
,
true
);
$user
[
"lockedKey"
]
=
$captcha
[
"key"
];
\App\PrometheusExporter
::
CaptchaShown
();
return
new
Response
(
view
(
'humanverification.captcha'
)
...
...
This diff is collapsed.
Click to expand it.
app/PrometheusExporter.php
0 → 100644
+
25
−
0
View file @
dc787fd2
<?php
namespace
App
;
class
PrometheusExporter
{
public
static
function
CaptchaShown
()
{
$registry
=
\Prometheus\CollectorRegistry
::
getDefault
();
$counter
=
$registry
->
getOrRegisterCounter
(
'metager'
,
'captcha_shown'
,
'counts how often the captcha was shown'
,
[]);
$counter
->
inc
();
}
public
static
function
CaptchaCorrect
()
{
$registry
=
\Prometheus\CollectorRegistry
::
getDefault
();
$counter
=
$registry
->
getOrRegisterCounter
(
'metager'
,
'captcha_correct'
,
'counts how often the captcha was solved correctly'
,
[]);
$counter
->
inc
();
}
public
static
function
CaptchaAnswered
()
{
$registry
=
\Prometheus\CollectorRegistry
::
getDefault
();
$counter
=
$registry
->
getOrRegisterCounter
(
'metager'
,
'captcha_answered'
,
'counts how often the captcha was answered'
,
[]);
$counter
->
inc
();
}
}
\ No newline at end of file
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