Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
kaniini
pleroma
Commits
0ec5aeb8
Commit
0ec5aeb8
authored
7 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
Don't log in deactivated users.
parent
e31a5ff4
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
lib/pleroma/plugs/authentication_plug.ex
+1
-0
1 addition, 0 deletions
lib/pleroma/plugs/authentication_plug.ex
lib/pleroma/plugs/oauth_plug.ex
+2
-1
2 additions, 1 deletion
lib/pleroma/plugs/oauth_plug.ex
test/plugs/authentication_plug_test.exs
+27
-0
27 additions, 0 deletions
test/plugs/authentication_plug_test.exs
with
30 additions
and
1 deletion
lib/pleroma/plugs/authentication_plug.ex
+
1
−
0
View file @
0ec5aeb8
...
...
@@ -12,6 +12,7 @@ defmodule Pleroma.Plugs.AuthenticationPlug do
def
call
(
conn
,
opts
)
do
with
{
:ok
,
username
,
password
}
<-
decode_header
(
conn
),
{
:ok
,
user
}
<-
opts
[
:fetcher
]
.
(
username
),
false
<-
!!user
.
info
[
"deactivated"
],
saved_user_id
<-
get_session
(
conn
,
:user_id
),
{
:ok
,
verified_user
}
<-
verify
(
user
,
password
,
saved_user_id
)
do
...
...
This diff is collapsed.
Click to expand it.
lib/pleroma/plugs/oauth_plug.ex
+
2
−
1
View file @
0ec5aeb8
...
...
@@ -16,7 +16,8 @@ defmodule Pleroma.Plugs.OAuthPlug do
end
with
token
when
not
is_nil
(
token
)
<-
token
,
%
Token
{
user_id:
user_id
}
<-
Repo
.
get_by
(
Token
,
token:
token
),
%
User
{}
=
user
<-
Repo
.
get
(
User
,
user_id
)
do
%
User
{}
=
user
<-
Repo
.
get
(
User
,
user_id
),
false
<-
!!user
.
info
[
"deactivated"
]
do
conn
|>
assign
(
:user
,
user
)
else
...
...
This diff is collapsed.
Click to expand it.
test/plugs/authentication_plug_test.exs
+
27
−
0
View file @
0ec5aeb8
...
...
@@ -14,6 +14,13 @@ defmodule Pleroma.Plugs.AuthenticationPlugTest do
password_hash:
Comeonin
.
Pbkdf2
.
hashpwsalt
(
"guy"
)
}
@deactivated
%
User
{
id:
1
,
name:
"dude"
,
password_hash:
Comeonin
.
Pbkdf2
.
hashpwsalt
(
"guy"
),
info:
%{
"deactivated"
=>
true
}
}
@session_opts
[
store:
:cookie
,
key:
"_test"
,
...
...
@@ -131,6 +138,26 @@ defmodule Pleroma.Plugs.AuthenticationPlugTest do
end
end
describe
"with a correct authorization header for an deactiviated user"
do
test
"it halts the appication"
,
%{
conn:
conn
}
do
opts
=
%{
optional:
false
,
fetcher:
fn
_
->
@deactivated
end
}
header
=
basic_auth_enc
(
"dude"
,
"guy"
)
conn
=
conn
|>
Plug
.
Session
.
call
(
Plug
.
Session
.
init
(
@session_opts
))
|>
fetch_session
|>
put_req_header
(
"authorization"
,
header
)
|>
AuthenticationPlug
.
call
(
opts
)
assert
conn
.
status
==
403
assert
conn
.
halted
==
true
end
end
describe
"with a user_id in the session for an existing user"
do
test
"it assigns the user"
,
%{
conn:
conn
}
do
opts
=
%{
...
...
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