#!/usr/bin/env php 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();