Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Pierre Boudes
mastodon
Commits
da9317fa
Commit
da9317fa
authored
7 years ago
by
Debanshu Kundu
Committed by
Eugen Rochko
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
#1456 Added rake task to add a user. (#1482)
parent
be92babd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/tasks/mastodon.rake
+31
-0
31 additions, 0 deletions
lib/tasks/mastodon.rake
with
31 additions
and
0 deletions
lib/tasks/mastodon.rake
+
31
−
0
View file @
da9317fa
...
...
@@ -42,6 +42,37 @@ namespace :mastodon do
end
end
desc
'Add a user by providing their email, username and initial password.'
\
'The user will receive a confirmation email, then they must reset their password before logging in.'
task
add_user: :environment
do
print
'Enter email: '
email
=
STDIN
.
gets
.
chomp
print
'Enter username: '
username
=
STDIN
.
gets
.
chomp
print
'Create user and send them confirmation mail [y/N]: '
confirm
=
STDIN
.
gets
.
chomp
puts
if
confirm
.
casecmp?
(
'y'
)
password
=
SecureRandom
.
hex
user
=
User
.
new
(
email:
email
,
password:
password
,
account_attributes:
{
username:
username
})
if
user
.
save
puts
'User added and confirmation mail sent to user\'s email address.'
puts
"Here is the random password generated for the user:
#{
password
}
"
else
puts
'Following errors occured while creating new user:'
user
.
errors
.
each
do
|
key
,
val
|
puts
"
#{
key
}
:
#{
val
}
"
end
end
else
puts
'Aborted by user.'
end
puts
end
namespace
:media
do
desc
'Removes media attachments that have not been assigned to any status for longer than a day'
task
clear: :environment
do
...
...
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