<p></p>
<p>Hello,<br>
I was trying to create script for setting up local copy of the website and noticed that tutorial's (configure.md) user management chapter needed manual actions to be made via website and ruby console. That got me wondering if there's way to automate it, but luckily there's pull request <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="777512526" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/3030" data-hovercard-type="pull_request" data-hovercard-url="/openstreetmap/openstreetmap-website/pull/3030/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/pull/3030">#3030</a> which covers populating database. I understand why such PR can't be merged due to cybersecurity concerns, but i believe some code snippets featured there, namely user creation, are worth mentioning or at least linking in tutorial.</p>
<p>Suggesting to add following bash command as automated alternative to adding dev-server admin/moderator:</p>
<div class="highlight highlight-source-ruby"><pre><span class="pl-en">bundle</span> <span class="pl-en">exec</span> <span class="pl-en">rails</span> <span class="pl-en">runner</span> <span class="pl-s">'admin = User.find_or_initialize_by(:email => "superadmin@osm.dev")</span>
<span class="pl-s">admin.update_attributes(</span>
<span class="pl-s"> :email => "superadmin@osm.dev",</span>
<span class="pl-s"> :email_valid => true,</span>
<span class="pl-s"> :display_name => "My New User Name",</span>
<span class="pl-s"> :description => "User description",</span>
<span class="pl-s"> :home_lat => "52.5170365",</span>
<span class="pl-s"> :home_lon => "13.3888599",</span>
<span class="pl-s"> :status => "confirmed",</span>
<span class="pl-s"> :terms_seen => true,</span>
<span class="pl-s"> :terms_agreed => Time.now.getutc,</span>
<span class="pl-s"> :data_public => true,</span>
<span class="pl-s"> :pass_crypt => "Str0ng_P4sSword",</span>
<span class="pl-s"> :pass_crypt_confirmation => "Str0ng_P4sSword",</span>
<span class="pl-s">)</span>
<span class="pl-s">admin.roles.create(:role => "administrator", :granter_id => admin.id )</span>
<span class="pl-s">admin.roles.create(:role => "moderator", :granter_id => admin.id)</span>
<span class="pl-s">admin.save!'</span></pre></div>
<p>PS. As a person, who has never used Ruby before, I think at some point user should be informed, that in order to access webpage from other devices, <code>-b 0.0.0.0</code> needs to be added to regular <code>bundle exec rails server</code> command. Figuring it out myself took me several hours of reading repo's code and stackoverflow. This is useful in scenario when someone sets up website on server OS, not desktop Linux.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/3136">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLLWAER44USLAUBUBPDTECIOFANCNFSM4ZKNPFUQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAK2OLJWZ4RNAEGTU7ZBW4LTECIOFA5CNFSM4ZKNPFU2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4MNQ7KCQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/3136",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/3136",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>