mirror of
https://github.com/cydrobolt/polr.git
synced 2024-11-10 04:02:28 +01:00
Fix delete button in admin interface, ensure registration fields are properly filled in, and correctly handle clicks
This commit is contained in:
parent
8f35b83e76
commit
53809cba28
@ -1,11 +1,13 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Helpers\ApiHelper;
|
||||
|
||||
class ApiController {
|
||||
class ApiController extends Controller {
|
||||
protected static function getApiUserInfo(Request $request) {
|
||||
$api_key = $request->input('key');
|
||||
$user = User::where('active', 1)
|
||||
@ -43,15 +45,4 @@ class ApiController {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
protected static function checkRequiredArgs($required_args=[]) {
|
||||
array_push($required_args, NULL);
|
||||
if (count(array_unique($required_args)) < count($required_args)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -27,4 +27,16 @@ class Controller extends BaseController {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected static function checkRequiredArgs($required_args=[]) {
|
||||
array_push($required_args, NULL);
|
||||
|
||||
if (count(array_unique($required_args)) < count($required_args)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -72,14 +72,14 @@ class LinkController extends Controller {
|
||||
}
|
||||
|
||||
$long_url = $link->long_url;
|
||||
$clicks = intval($link->clicks);
|
||||
|
||||
if (is_int($link->clicks)) {
|
||||
$link->clicks += 1;
|
||||
}
|
||||
else {
|
||||
$link->clicks = 1;
|
||||
if (is_int($clicks)) {
|
||||
$clicks += 1;
|
||||
}
|
||||
|
||||
$link->clicks = $clicks;
|
||||
|
||||
$link->save();
|
||||
|
||||
LinkHelper::processPostClick($link);
|
||||
|
@ -52,6 +52,12 @@ class UserController extends Controller {
|
||||
$username = $request->input('username');
|
||||
$password = $request->input('password');
|
||||
$email = $request->input('email');
|
||||
|
||||
if (!self::checkRequiredArgs([$username, $password, $email])) {
|
||||
// missing a required argument
|
||||
return redirect(route('signup'))->with('error', 'Please fill in all required fields.');
|
||||
}
|
||||
|
||||
$ip = $request->ip();
|
||||
|
||||
$user_exists = UserHelper::userExists($username);
|
||||
@ -59,13 +65,13 @@ class UserController extends Controller {
|
||||
|
||||
if ($user_exists || $email_exists) {
|
||||
// if user or email email
|
||||
return redirect('signup')->with('error', 'Sorry, your email or username already exists. Try again.');
|
||||
return redirect(route('signup'))->with('error', 'Sorry, your email or username already exists. Try again.');
|
||||
}
|
||||
|
||||
$email_valid = UserHelper::validateEmail($email);
|
||||
|
||||
if ($email_valid == false) {
|
||||
return redirect('signup')->with('error', 'Please use a valid email to sign up.');
|
||||
return redirect(route('signup'))->with('error', 'Please use a valid email to sign up.');
|
||||
}
|
||||
|
||||
$acct_activation_needed = env('POLR_ACCT_ACTIVATION');
|
||||
@ -73,7 +79,7 @@ class UserController extends Controller {
|
||||
if ($acct_activation_needed == false) {
|
||||
// if no activation is necessary
|
||||
$active = 1;
|
||||
$response = redirect('login')->with('success', 'Thanks for signing up! You may now log in.');
|
||||
$response = redirect(route('login'))->with('success', 'Thanks for signing up! You may now log in.');
|
||||
}
|
||||
else {
|
||||
// email activation is necessary
|
||||
@ -82,7 +88,7 @@ class UserController extends Controller {
|
||||
], function ($m) use ($user) {
|
||||
$m->to($user->email, $user->username)->subject(env('APP_NAME') . ' account activation');
|
||||
});
|
||||
$response = redirect('login')->with('success', 'Thanks for signing up! Please confirm your email to continue..');
|
||||
$response = redirect(route('login'))->with('success', 'Thanks for signing up! Please confirm your email to continue..');
|
||||
$active = 0;
|
||||
}
|
||||
$user = UserFactory::createUser($username, $email, $password, $active, $ip);
|
||||
|
@ -30,7 +30,7 @@
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<a class='delete-user btn btn-sm btn-danger @if (session('username') == $user->username)btn-disabled @endif'
|
||||
<a class='delete-user btn btn-sm btn-danger @if (session('username') == $user->username)disabled @endif'
|
||||
|
||||
data-user-id='{{$user->id}}'>
|
||||
Delete
|
||||
|
Loading…
Reference in New Issue
Block a user