Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2890878
setup.php
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
setup.php
View Options
#!/usr/bin/env php
<?php
require_once
'./scripts/__init_script__.php'
;
$query
=
new
PhabricatorAuthProviderConfigQuery
(
)
;
$config
=
$query
->
setViewer
(
PhabricatorUser
::
getOmnipotentUser
(
)
)
->
withIDs
(
array
(
1
)
)
->
executeOne
(
)
;
if
(
$config
)
{
echo
phutil_console_wrap
(
"User/Password Auth Provider already configured\n"
)
;
return
;
}
echo
phutil_console_wrap
(
"Setting up dev environment with user admin/hunter2\n"
)
;
$password1
=
new
PhutilOpaqueEnvelope
(
'hunter2'
)
;
$config
=
id
(
new
PhabricatorAuthProviderConfig
(
)
)
->
setIsEnabled
(
1
)
->
setShouldAllowLogin
(
1
)
->
setShouldAllowRegistration
(
true
)
->
setShouldAllowLink
(
1
)
->
setShouldAllowUnlink
(
true
)
->
setProviderType
(
'password'
)
->
setProviderDomain
(
'self'
)
->
setProviderClass
(
'PhabricatorPasswordAuthProvider'
)
->
save
(
)
;
$user
=
new
PhabricatorUser
(
)
;
$user
->
setUsername
(
'admin'
)
;
$user
->
setRealName
(
'admin'
)
;
$email
=
id
(
new
PhabricatorUserEmail
(
)
)
->
setAddress
(
'admin@example.com'
)
->
setIsVerified
(
1
)
;
$user
->
setIsApproved
(
1
)
;
id
(
new
PhabricatorUserEditor
(
)
)
->
setActor
(
PhabricatorUser
::
getOmnipotentUser
(
)
)
->
createNewUser
(
$user
,
$email
)
;
$xactions
=
array
(
)
;
$xactions
[
]
=
id
(
new
PhabricatorUserTransaction
(
)
)
->
setTransactionType
(
PhabricatorUserEmpowerTransaction
::
TRANSACTIONTYPE
)
->
setNewValue
(
true
)
;
$source
=
id
(
new
PhabricatorUnknownContentSource
(
)
)
;
$actor
=
PhabricatorUser
::
getOmnipotentUser
(
)
;
$people_application_phid
=
id
(
new
PhabricatorPeopleApplication
(
)
)
->
getPHID
(
)
;
$editor
=
id
(
new
PhabricatorUserTransactionEditor
(
)
)
->
setActor
(
$actor
)
->
setContentSource
(
$source
)
->
setActingAsPHID
(
$people_application_phid
)
->
setContinueOnMissingFields
(
true
)
;
$editor
->
applyTransactions
(
$user
,
$xactions
)
;
$pass
=
PhabricatorAuthPassword
::
initializeNewPassword
(
$user
,
PhabricatorAuthPassword
::
PASSWORD_TYPE_ACCOUNT
)
->
setPassword
(
$password1
,
$user
)
->
save
(
)
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 19, 14:17 (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1125413
Default Alt Text
setup.php (1 KB)
Attached To
Mode
R13 DeepClone
Attached
Detach File
Event Timeline
Log In to Comment