Register user via Logical Theme #3697

Closed
opened 2026-02-05 07:12:40 +03:00 by OVERLORD · 0 comments
Owner

Originally created by @HenrikPec on GitHub (Mar 27, 2023).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Hi,

according to the following instruction, I managed to login users via client certificate.
In the past I've done this changing the LoginController. Reading the issue showed my a clearly nicer way.

https://github.com/BookStackApp/BookStack/pull/2289#issuecomment-857164663

Could you give me a hint how I can add the UserRepo to the logical theme. I would like the user to automatically get registered if not exists.
I'm not sure how to get the UserRepo object.

Thanks

        if ($proxyEmail && !auth()->check()) {
            $user = User::query()->where($authUserAttribute, '=', $proxyEmail)->first();
            if ($user) {
                auth()->login($user);
            }
            else
            {
                print ("Register") ;
                $registerData = [];
                $registerData['name'] = $proxyUsername;
                $registerData['email'] = $proxyEmail ;
                $registerData['password'] = sha1(rand());
                $newUser = (new UserRepo())->create($registerData);
                $viewRole = Role::getRole('Viewer');
                $newUser->attachRole($viewRole);             

                auth()->login($newUser);
                return redirect()->intended('/');   
            }

        }

Exact BookStack Version

BookStack v22.10.2

Log Content

No response

PHP Version

8.1

Hosting Environment

Windows with IIS

Originally created by @HenrikPec on GitHub (Mar 27, 2023). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario Hi, according to the following instruction, I managed to login users via client certificate. In the past I've done this changing the LoginController. Reading the issue showed my a clearly nicer way. https://github.com/BookStackApp/BookStack/pull/2289#issuecomment-857164663 Could you give me a hint how I can add the UserRepo to the logical theme. I would like the user to automatically get registered if not exists. I'm not sure how to get the UserRepo object. Thanks ``` if ($proxyEmail && !auth()->check()) { $user = User::query()->where($authUserAttribute, '=', $proxyEmail)->first(); if ($user) { auth()->login($user); } else { print ("Register") ; $registerData = []; $registerData['name'] = $proxyUsername; $registerData['email'] = $proxyEmail ; $registerData['password'] = sha1(rand()); $newUser = (new UserRepo())->create($registerData); $viewRole = Role::getRole('Viewer'); $newUser->attachRole($viewRole); auth()->login($newUser); return redirect()->intended('/'); } } ``` ### Exact BookStack Version BookStack v22.10.2 ### Log Content _No response_ ### PHP Version 8.1 ### Hosting Environment Windows with IIS
OVERLORD added the 🐕 Support label 2026-02-05 07:12:40 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3697