wip
This commit is contained in:
@ -25,6 +25,7 @@ use TheTempusProject\TheTempusProject as App;
|
||||
use TheTempusProject\Classes\Controller;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Plugins\Turnstile;
|
||||
|
||||
class Register extends Controller {
|
||||
public function confirm( $code = null ) {
|
||||
@ -47,22 +48,40 @@ class Register extends Controller {
|
||||
public function index() {
|
||||
self::$title = '{SITENAME} Sign Up';
|
||||
self::$pageDescription = 'Many features of {SITENAME} are disabled or hidden from unregistered users. On this page you can sign up for an account to access all the app has to offer.';
|
||||
|
||||
if ( ! Config::getValue( 'main/registrationEnabled' ) ) {
|
||||
return Issues::add( 'notice', 'The site administrator has disable the ability to register a new account.' );
|
||||
}
|
||||
|
||||
$turnstile = '';
|
||||
if ( class_exists( 'TheTempusProject\Plugins\Turnstile' ) ) {
|
||||
$turnstile = new Turnstile;
|
||||
if ( ! $turnstile->checkEnabled() ) {
|
||||
Components::set( 'TURNSTILE_WIDGET', '' );
|
||||
$turnstile = '';
|
||||
}
|
||||
} else {
|
||||
Components::set( 'TURNSTILE_WIDGET', '' );
|
||||
}
|
||||
Components::set( 'TERMS', Views::simpleView( 'auth.terms' ) );
|
||||
if ( App::$isLoggedIn ) {
|
||||
return Issues::add( 'notice', 'You are currently logged in.' );
|
||||
}
|
||||
if ( !Input::exists() ) {
|
||||
if ( ! Input::exists() ) {
|
||||
return Views::view( 'auth.register' );
|
||||
}
|
||||
if ( !Forms::check( 'register' ) ) {
|
||||
if ( Input::exists( 'userEmail' ) ) {
|
||||
// for the really bad AI / headless bots
|
||||
Session::flash( 'success', 'Thank you for registering! Please check your email to confirm your account.' );
|
||||
Redirect::to( 'home/index' );
|
||||
}
|
||||
if ( ! Forms::check( 'register' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your registration.' => Check::userErrors() ] );
|
||||
return Views::view( 'auth.register' );
|
||||
}
|
||||
if ( ! empty( $turnstile ) ) {
|
||||
if ( empty( $turnstile->verify() ) ) {
|
||||
return Views::view( 'auth.register' );
|
||||
}
|
||||
}
|
||||
self::$user->create( [
|
||||
'username' => Input::post( 'username' ),
|
||||
'password' => Hash::make( Input::post( 'password' ) ),
|
||||
|
Reference in New Issue
Block a user