Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
968d7490
Commit
968d7490
authored
Dec 19, 2018
by
Ivan Tashkinov
Browse files
[
#114
] User.Info: renamed `confirmation_update` to `confirmation_changeset`.
parent
59fc5d15
Changes
5
Show whitespace changes
Inline
Side-by-side
lib/pleroma/user.ex
View file @
968d7490
...
...
@@ -191,7 +191,7 @@ def register_changeset(struct, params \\ %{}, opts \\ []) do
|>
validate_format
(
:email
,
@email_regex
)
|>
validate_length
(
:bio
,
max:
1000
)
|>
validate_length
(
:name
,
min:
1
,
max:
100
)
|>
put_change
(
:info
,
User
.
Info
.
confirmation_change
(%
User
.
Info
{},
confirmation_status
))
|>
put_change
(
:info
,
User
.
Info
.
confirmation_change
set
(%
User
.
Info
{},
confirmation_status
))
if
changeset
.
valid?
do
hashed
=
Pbkdf2
.
hashpwsalt
(
changeset
.
changes
[
:password
])
...
...
lib/pleroma/user/info.ex
View file @
968d7490
...
...
@@ -143,21 +143,21 @@ def profile_update(info, params) do
])
end
def
confirmation_change
(
info
,
:confirmed
)
do
confirmation_change
(
info
,
%{
def
confirmation_change
set
(
info
,
:confirmed
)
do
confirmation_change
set
(
info
,
%{
confirmation_pending:
false
,
confirmation_token:
nil
})
end
def
confirmation_change
(
info
,
:unconfirmed
)
do
confirmation_change
(
info
,
%{
def
confirmation_change
set
(
info
,
:unconfirmed
)
do
confirmation_change
set
(
info
,
%{
confirmation_pending:
true
,
confirmation_token:
:crypto
.
strong_rand_bytes
(
32
)
|>
Base
.
url_encode64
()
})
end
def
confirmation_change
(
info
,
params
)
do
def
confirmation_change
set
(
info
,
params
)
do
cast
(
info
,
params
,
[
:confirmation_pending
,
:confirmation_token
])
end
...
...
lib/pleroma/web/twitter_api/twitter_api_controller.ex
View file @
968d7490
...
...
@@ -376,7 +376,7 @@ def password_reset(conn, params) do
def
confirm_email
(
conn
,
%{
"token"
=>
token
})
do
with
%
User
{}
=
user
<-
User
.
get_by_confirmation_token
(
token
),
true
<-
user
.
local
,
info_change
<-
User
.
Info
.
confirmation_change
(
user
.
info
,
:confirmed
),
info_change
<-
User
.
Info
.
confirmation_change
set
(
user
.
info
,
:confirmed
),
changeset
<-
Changeset
.
change
(
user
)
|>
Changeset
.
put_embed
(
:info
,
info_change
),
{
:ok
,
_
}
<-
User
.
update_and_set_cache
(
changeset
)
do
conn
...
...
test/web/oauth/oauth_controller_test.exs
View file @
968d7490
...
...
@@ -116,7 +116,7 @@ test "rejects token exchange with invalid client credentials" do
test
"rejects token exchange for valid credentials belonging to unconfirmed user"
do
password
=
"testpassword"
user
=
insert
(
:user
,
password_hash:
Comeonin
.
Pbkdf2
.
hashpwsalt
(
password
))
info_change
=
Pleroma
.
User
.
Info
.
confirmation_change
(
user
.
info
,
:unconfirmed
)
info_change
=
Pleroma
.
User
.
Info
.
confirmation_change
set
(
user
.
info
,
:unconfirmed
)
{
:ok
,
user
}
=
user
...
...
test/web/twitter_api/twitter_api_controller_test.exs
View file @
968d7490
...
...
@@ -876,7 +876,7 @@ test "it returns 500 when user is not local", %{conn: conn, user: user} do
describe
"GET /api/account/confirm_email/:token"
do
setup
do
user
=
insert
(
:user
)
info_change
=
User
.
Info
.
confirmation_change
(
user
.
info
,
:unconfirmed
)
info_change
=
User
.
Info
.
confirmation_change
set
(
user
.
info
,
:unconfirmed
)
{
:ok
,
user
}
=
user
...
...
@@ -908,7 +908,7 @@ test "it confirms the user account", %{conn: conn, user: user} do
describe
"POST /api/account/resend_confirmation_email"
do
setup
do
user
=
insert
(
:user
)
info_change
=
User
.
Info
.
confirmation_change
(
user
.
info
,
:unconfirmed
)
info_change
=
User
.
Info
.
confirmation_change
set
(
user
.
info
,
:unconfirmed
)
{
:ok
,
user
}
=
user
...
...
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