Map domain to specific profile
Admins can now map domains to specific profiles. To do this add this array to your advanced config: 'custom_domains' => [ ['domain' => 'example.com', 'name' => 'example_user',], ['domain' => 'example.example.com', 'id' => '1',], // more entries as needed ], For each entry, a domain and user name or id has to be defined.
This commit is contained in:
parent
b80455e34d
commit
bbad48998b
|
@ -84,8 +84,13 @@ class UserController extends Controller
|
|||
//Show littlelink page. example => http://127.0.0.1:8000/+admin
|
||||
public function littlelink(request $request)
|
||||
{
|
||||
$littlelink_name = $request->littlelink;
|
||||
$id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id');
|
||||
if(isset($request->useif)){
|
||||
$littlelink_name = User::select('littlelink_name')->where('id', $request->littlelink)->value('littlelink_name');
|
||||
$id = $request->littlelink;
|
||||
} else {
|
||||
$littlelink_name = $request->littlelink;
|
||||
$id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id');
|
||||
}
|
||||
|
||||
if (empty($id)) {
|
||||
return abort(404);
|
||||
|
@ -103,6 +108,24 @@ class UserController extends Controller
|
|||
return view('linkstack.linkstack', ['userinfo' => $userinfo, 'information' => $information, 'links' => $links, 'littlelink_name' => $littlelink_name]);
|
||||
}
|
||||
|
||||
//Show littlelink page as home page if set in config
|
||||
public function littlelinkhome(request $request)
|
||||
{
|
||||
$littlelink_name = env('HOME_URL');
|
||||
$id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id');
|
||||
|
||||
if (empty($id)) {
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
$userinfo = User::select('id', 'name', 'littlelink_name', 'littlelink_description', 'theme', 'role', 'block')->where('id', $id)->first();
|
||||
$information = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->get();
|
||||
|
||||
$links = DB::table('links')->join('buttons', 'buttons.id', '=', 'links.button_id')->select('links.link', 'links.id', 'links.button_id', 'links.title', 'links.custom_css', 'links.custom_icon', 'buttons.name')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->get();
|
||||
|
||||
return view('linkstack.linkstack', ['userinfo' => $userinfo, 'information' => $information, 'links' => $links, 'littlelink_name' => $littlelink_name]);
|
||||
}
|
||||
|
||||
//Redirect to user page
|
||||
public function userRedirect(request $request)
|
||||
{
|
||||
|
@ -120,24 +143,6 @@ class UserController extends Controller
|
|||
return redirect(url('@'.$user));
|
||||
}
|
||||
|
||||
//Show littlelink page as home page if set in config
|
||||
public function littlelinkhome(request $request)
|
||||
{
|
||||
$littlelink_name = env('HOME_URL');
|
||||
$id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id');
|
||||
|
||||
if (empty($id)) {
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
$userinfo = User::select('id', 'name', 'littlelink_name', 'littlelink_description', 'theme', 'role')->where('id', $id)->first();
|
||||
$information = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->get();
|
||||
|
||||
$links = DB::table('links')->join('buttons', 'buttons.id', '=', 'links.button_id')->select('links.link', 'links.id', 'links.button_id', 'links.title', 'links.custom_css', 'links.custom_icon', 'buttons.name')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->get();
|
||||
|
||||
return view('linkstack.linkstack', ['userinfo' => $userinfo, 'information' => $information, 'links' => $links, 'littlelink_name' => $littlelink_name]);
|
||||
}
|
||||
|
||||
//Show add/update form
|
||||
public function AddUpdateLink($id = 0)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
use App\Http\Controllers\UserController;
|
||||
|
||||
$host = request()->getHost();
|
||||
$customConfigs = config('advanced-config.custom_domains', []);
|
||||
|
||||
foreach ($customConfigs as $config) {
|
||||
if ($host == $config['domain']) {
|
||||
$routeCallback = function () use ($config) {
|
||||
$request = app('request');
|
||||
$request->merge(['littlelink' => isset($config['name']) ? $config['name'] : $config['id']]);
|
||||
if (isset($config['id'])) {
|
||||
$request->merge(['useif' => 'true']);
|
||||
}
|
||||
return app(UserController::class)->littlelink($request);
|
||||
};
|
||||
|
||||
Route::get('/', $routeCallback)->name('littlelink');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$customHomeUrl = config('advanced-config.custom_home_url', '/home');
|
||||
$disableHomePageConfig = config('advanced-config.disable_home_page');
|
||||
$redirectHomePageConfig = config('advanced-config.redirect_home_page');
|
||||
|
||||
if (env('HOME_URL') != '') {
|
||||
Route::get('/', [UserController::class, 'littlelinkhome'])->name('littlelink');
|
||||
if ($disableHomePageConfig == 'redirect') {
|
||||
Route::get($customHomeUrl, function () use ($redirectHomePageConfig) {
|
||||
return redirect($redirectHomePageConfig);
|
||||
});
|
||||
} elseif ($disableHomePageConfig != 'true') {
|
||||
Route::get($customHomeUrl, [App\Http\Controllers\HomeController::class, 'home'])->name('home');
|
||||
}
|
||||
} else {
|
||||
if ($disableHomePageConfig == 'redirect') {
|
||||
Route::get('/', function () use ($redirectHomePageConfig) {
|
||||
return redirect($redirectHomePageConfig);
|
||||
});
|
||||
} elseif ($disableHomePageConfig != 'true') {
|
||||
Route::get('/', [App\Http\Controllers\HomeController::class, 'home'])->name('home');
|
||||
}
|
||||
}
|
|
@ -54,24 +54,7 @@ if(file_exists(base_path('INSTALLING')) or file_exists(base_path('INSTALLERLOCK'
|
|||
// Disables routes if in Maintenance Mode
|
||||
if(env('MAINTENANCE_MODE') != 'true'){
|
||||
|
||||
//Changes the homepage to a LinkStack profile if set in the config
|
||||
if(config('advanced-config.custom_home_url') != '') {
|
||||
$custom_home_page_url = config('advanced-config.custom_home_url');
|
||||
} else {
|
||||
$custom_home_page_url = "/home";
|
||||
}
|
||||
if(env('HOME_URL') != '') {
|
||||
Route::get('/', [UserController::class, 'littlelinkhome'])->name('littlelink');
|
||||
if(config('advanced-config.disable_home_page') == 'redirect') {
|
||||
Route::get($custom_home_page_url, function () {return redirect(config('advanced-config.redirect_home_page'));});
|
||||
}elseif(config('advanced-config.disable_home_page') != 'true') {
|
||||
Route::get( $custom_home_page_url, [App\Http\Controllers\HomeController::class, 'home'])->name('home');}
|
||||
} else {
|
||||
if(config('advanced-config.disable_home_page') == 'redirect') {
|
||||
Route::get('/', function () {return redirect(config('advanced-config.redirect_home_page'));});
|
||||
}elseif(config('advanced-config.disable_home_page') != 'true') {
|
||||
Route::get('/', [App\Http\Controllers\HomeController::class, 'home'])->name('home');}
|
||||
}
|
||||
require __DIR__.'/home.php';
|
||||
|
||||
//Redirect if no page URL is set
|
||||
Route::get('/@', function () {
|
||||
|
|
Loading…
Reference in New Issue