mirror of
https://github.com/cydrobolt/polr.git
synced 2024-11-09 11:42:28 +01:00
Refactor, fix setup variable access
This commit is contained in:
parent
e2314dd8ff
commit
ba4865a00f
@ -47,7 +47,7 @@ class AdminPaginationController extends Controller {
|
||||
->addColumn('change_role', function ($user) {
|
||||
// Add "change role" select box
|
||||
// FIXME <select> field does not use Angular bindings
|
||||
// because of an issue afflicting fields with duplicate names.
|
||||
// because of an issue affecting fields with duplicate names.
|
||||
|
||||
$select_role = '<select ng-init="changeUserRole.u'.$user->id.' = \''.$user->role.'\'"
|
||||
ng-model="changeUserRole.u'.$user->id.'" ng-change="changeUserRole(changeUserRole.u'.$user->id.', '.$user->id.')"
|
||||
|
@ -98,7 +98,7 @@ class SetupController extends Controller {
|
||||
$acct_username = $request->input('acct:username');
|
||||
$acct_email = $request->input('acct:email');
|
||||
$acct_password = $request->input('acct:password');
|
||||
$acct_group = UserHelper::UserRole('ADMIN');
|
||||
$acct_group = UserHelper::USER_ROLES('admin');
|
||||
|
||||
// if true, only logged in users can shorten
|
||||
$st_shorten_permission = $request->input('setting:shorten_permission');
|
||||
@ -215,7 +215,7 @@ class SetupController extends Controller {
|
||||
return redirect(route('setup'))->with('error', 'Could not create database. Perhaps some credentials were incorrect?');
|
||||
}
|
||||
|
||||
$user = UserFactory::createUser($setup_finish_args->acct_username, $setup_finish_args->acct_email, $setup_finish_args->acct_password, 1, $request->ip(), false, 0, UserHelper::UserRole('ADMIN'));
|
||||
$user = UserFactory::createUser($setup_finish_args->acct_username, $setup_finish_args->acct_email, $setup_finish_args->acct_password, 1, $request->ip(), false, 0, UserHelper::USER_ROLES('admin'));
|
||||
|
||||
return view('setup_thanks')->with('success', 'Set up completed! Thanks for using Polr!');
|
||||
}
|
||||
|
@ -104,7 +104,6 @@ class UserController extends Controller {
|
||||
$api_key = CryptoHelper::generateRandomHex(env('_API_KEY_LENGTH'));
|
||||
}
|
||||
|
||||
|
||||
$user = UserFactory::createUser($username, $email, $password, $active, $ip, $api_key, $api_active);
|
||||
|
||||
if ($acct_activation_needed) {
|
||||
|
@ -6,6 +6,11 @@
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Optional endpoints */
|
||||
if (env('POLR_ALLOW_ACCT_CREATION')) {
|
||||
$app->get('/signup', ['as' => 'signup', 'uses' => 'UserController@displaySignupPage']);
|
||||
$app->post('/signup', ['as' => 'psignup', 'uses' => 'UserController@performSignup']);
|
||||
}
|
||||
|
||||
/* GET endpoints */
|
||||
|
||||
@ -13,8 +18,7 @@ $app->get('/', ['as' => 'index', 'uses' => 'IndexController@showIndexPage']);
|
||||
$app->get('/logout', ['as' => 'logout', 'uses' => 'UserController@performLogoutUser']);
|
||||
$app->get('/login', ['as' => 'login', 'uses' => 'UserController@displayLoginPage']);
|
||||
$app->get('/about', ['as' => 'about', 'uses' => 'StaticPageController@displayAbout']);
|
||||
if (env('POLR_ALLOW_ACCT_CREATION'))
|
||||
$app->get('/signup', ['as' => 'signup', 'uses' => 'UserController@displaySignupPage']);
|
||||
|
||||
$app->get('/lost_password', ['as' => 'lost_password', 'uses' => 'UserController@displayLostPasswordPage']);
|
||||
$app->get('/activate/{username}/{recovery_key}', ['as' => 'activate', 'uses' => 'UserController@performActivation']);
|
||||
$app->get('/reset_password/{username}/{recovery_key}', ['as' => 'reset_password', 'uses' => 'UserController@performPasswordReset']);
|
||||
@ -32,8 +36,6 @@ $app->get('/{short_url}/{secret_key}', ['uses' => 'LinkController@performRedirec
|
||||
/* POST endpoints */
|
||||
|
||||
$app->post('/login', ['as' => 'plogin', 'uses' => 'UserController@performLogin']);
|
||||
if (env('POLR_ALLOW_ACCT_CREATION'))
|
||||
$app->post('/signup', ['as' => 'psignup', 'uses' => 'UserController@performSignup']);
|
||||
$app->post('/shorten', ['as' => 'pshorten', 'uses' => 'LinkController@performShorten']);
|
||||
$app->post('/lost_password', ['as' => 'plost_password', 'uses' => 'UserController@performSendPasswordResetCode']);
|
||||
$app->post('/reset_password/{username}/{recovery_key}', ['as' => 'preset_password', 'uses' => 'UserController@performPasswordReset']);
|
||||
|
@ -46,11 +46,6 @@ input.api-quota {
|
||||
}
|
||||
}
|
||||
|
||||
/* User Management Styles */
|
||||
select.new-user-role {
|
||||
|
||||
}
|
||||
|
||||
a.new-user-add {
|
||||
padding-left: 0.5em
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ polr.controller('AdminCtrl', function($scope, $compile) {
|
||||
var user_role = $('#new-user-role').val();
|
||||
|
||||
if (!$scope.checkNewUserFields()) {
|
||||
$('#new-user-status').text('Fields cannot be empty.');
|
||||
toastr.error("Fields cannot be empty.", "Error");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ polr.controller('AdminCtrl', function($scope, $compile) {
|
||||
$('#new-user-form').clearForm();
|
||||
$scope.datatables['admin_users_table'].ajax.reload();
|
||||
}, function () {
|
||||
$('#new-user-status').text('An error occurred. Try again later.').show();
|
||||
toastr.error("An error occured while creating the user.", "Error");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,6 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="new-user-status"></div>
|
||||
</div>
|
||||
|
||||
@include('snippets.user_table', [
|
||||
|
@ -20,7 +20,7 @@
|
||||
<li class="divider-vertical"></li>
|
||||
|
||||
@if (empty(session('username')))
|
||||
@if (env('POLR_ALLOW_ACCT_CREATION') == true)
|
||||
@if (env('POLR_ALLOW_ACCT_CREATION'))
|
||||
<li><a href="{{route('signup')}}">Sign Up</a></li>
|
||||
@endif
|
||||
<li class="dropdown">
|
||||
@ -36,7 +36,7 @@
|
||||
</div>
|
||||
</li>
|
||||
@else
|
||||
<div class='nav pull-right navbar-nav' style='color: white'>
|
||||
<div class='nav pull-right navbar-nav'>
|
||||
<li class='dropdown'>
|
||||
<a class="dropdown-toggle login-name" href="#" data-toggle="dropdown">{{session('username')}} <strong class="caret"></strong></a>
|
||||
<ul class="dropdown-menu pull-right" role="menu" aria-labelledby="dropdownMenu">
|
||||
|
Loading…
Reference in New Issue
Block a user