/**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Contracts\Auth\CanResetPassword|User|ServiceUser $user
  * @param  string                                                       $password
  */
 protected function resetPassword($user, $password)
 {
     $user->password_text = bcrypt($password);
     $user->save();
     /** @noinspection PhpUndefinedMethodInspection */
     Auth::login($user);
 }
Ejemplo n.º 2
0
 /**
  * Registers the first admin user to identify the DFE installation
  *
  * @param \DreamFactory\Enterprise\Database\Models\ServiceUser $serviceUser
  *
  * @return bool|mixed|\stdClass
  */
 public function registerAdmin(ServiceUser $serviceUser)
 {
     //  Get url and send data
     if (null === ($_url = config('license.endpoints.admin'))) {
         \Log::warning('[dfe.license] No "admin" license endpoint configured.');
         return false;
     }
     return $this->postData($_url, $serviceUser->toArray());
 }
Ejemplo n.º 3
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array $data
  *
  * @return User
  */
 public function create(array $data)
 {
     $_serviceUser = ServiceUser::create(['first_name_text' => array_get($data, 'first_name_text'), 'last_name_text' => array_get($data, 'last_name_text'), 'email_addr_text' => array_get($data, 'email_addr_text'), 'nickname_text' => array_get($data, 'nick_name_text'), 'password_text' => \Hash::make(array_get($data, 'password_text'))]);
     //  If this is the first registered user, post registration
     if (1 == ServiceUser::count()) {
         $this->postRegistration($_serviceUser);
     }
     return $_serviceUser;
 }
 /**
  * @param ServiceUser $user
  * @param bool        $remember
  *
  * @return bool|int
  */
 public function handle(ServiceUser $user, $remember)
 {
     logger('[auth.login] ' . $user->email_addr_text . ' authorization');
     return $user->update(['last_login_date' => $user->freshTimestamp(), 'last_login_ip_text' => $this->request->getClientIp()]);
 }
Ejemplo n.º 5
0
 /**
  * @return bool
  */
 protected function _backupServiceUsers()
 {
     $_backupPath = base_path() . DIRECTORY_SEPARATOR . 'database' . DIRECTORY_SEPARATOR . 'dfe';
     if (!Disk::ensurePath($_backupPath)) {
         $this->writeln('Unable to write to backup path <comment>' . $_backupPath . '</comment>. Aborting.', 'error');
         return false;
     }
     $_users = [];
     /** @type ServiceUser $_user */
     foreach (ServiceUser::all() as $_user) {
         $_users[] = $_user->toArray();
     }
     JsonFile::encodeFile($_backupPath . DIRECTORY_SEPARATOR . 'service-user.backup.' . date('YmdHis') . '.json', $_users);
     return true;
 }
Ejemplo n.º 6
0
 /**
  * @return array
  */
 protected function gatherConsoleStatistics()
 {
     $_stats = ['uri' => config('app.url', \Request::getSchemeAndHttpHost()), 'user' => ServiceUser::count(), 'mount' => Mount::count(), 'server' => Server::count(), 'cluster' => Cluster::count(), 'limit' => Limit::count(), 'instance' => Instance::count()];
     return $_stats;
     //  The new way
     //return $this->telemetry->make('console')->getTelemetry();
 }
Ejemplo n.º 7
0
 /**
  * @param int $serviceUserId
  *
  * @return User
  */
 protected static function findServiceUser($serviceUserId)
 {
     return ServiceUser::findOrFail($serviceUserId);
 }
Ejemplo n.º 8
0
 public function index()
 {
     $users_owners = new ServiceUser();
     $users_admins = new User();
     $_columns = ['id', 'first_name_text', 'last_name_text', 'nickname_text', 'email_addr_text', 'owner_id', 'active_ind'];
     $o_users = $users_owners->get($_columns);
     $a_users = $users_admins->get($_columns);
     $o_users_array = json_decode($o_users);
     $a_users_array = json_decode($a_users);
     array_walk($o_users_array, function (&$o_user_array) {
         $o_user_array->admin = true;
     });
     array_walk($a_users_array, function (&$a_user_array) {
         $a_user_array->admin = false;
     });
     $result = array_merge($o_users_array, $a_users_array);
     $result = array_map("unserialize", array_unique(array_map("serialize", $result)));
     sort($result);
     return $this->renderView('app.users', ['users' => $result]);
 }