diff --git a/app/Controllers/AuthController.php b/app/Controllers/AuthController.php index d472fb8..181a8221 100644 --- a/app/Controllers/AuthController.php +++ b/app/Controllers/AuthController.php @@ -49,8 +49,7 @@ class AuthController extends Controller // Destroy the active session CurrentSession::stop(); - // Return true indicating a successful logout - return redirect(route('auth.login')); + return redirect(route('main.index')); } /** @@ -60,16 +59,12 @@ class AuthController extends Controller public function login(): string { if (!session_check()) { - return view('auth/login'); + return $this->json(['error' => 'Your session expired! Please refresh and try again.', 'a' => $_POST]); } - // Preliminarily set login to failed - $redirect = route('auth.login'); - // Get request variables - $username = $_REQUEST['username'] ?? null; - $password = $_REQUEST['password'] ?? null; - $remember = isset($_REQUEST['remember']); + $username = $_POST['username'] ?? null; + $password = $_POST['password'] ?? null; // Check if we haven't hit the rate limit $rates = DB::table('login_attempts') @@ -79,38 +74,30 @@ class AuthController extends Controller ->count(); if ($rates > 4) { - $message = 'Your have hit the login rate limit, try again later.'; - return view('global/information', compact('message', 'redirect')); + return $this->json(['error' => 'Your have hit the login rate limit, try again later.']); } - // Get account data $user = User::construct(clean_string($username, true, true)); // Check if the user that's trying to log in actually exists if ($user->id === 0) { $this->touchRateLimit($user->id); - $message = 'The user you tried to log into does not exist.'; - return view('global/information', compact('message', 'redirect')); + return $this->json(['error' => 'The user you tried to log into does not exist.']); } if ($user->passwordExpired()) { - $message = 'Your password expired.'; - $redirect = route('auth.resetpassword'); - return view('global/information', compact('message', 'redirect')); + return $this->json(['error' => 'Your password expired.']); } if (!$user->verifyPassword($password)) { $this->touchRateLimit($user->id); - $message = 'The password you entered was invalid.'; - return view('global/information', compact('message', 'redirect')); + return $this->json(['error' => 'The password you entered was invalid.']); } // Check if the user has the required privs to log in if (!$user->activated) { $this->touchRateLimit($user->id); - $message = 'Your account is deactivated, activate it first!'; - $redirect = route('auth.reactivate'); - return view('global/information', compact('message', 'redirect')); + return $this->json(['error' => "Your account isn't activated, check your e-mail!"]); } // Generate a session key @@ -118,33 +105,22 @@ class AuthController extends Controller $user->id, Net::ip(), get_country_code(), - clean_string($_SERVER['HTTP_USER_AGENT'] ?? ''), - $remember + clean_string($_SERVER['HTTP_USER_AGENT'] ?? '') ); $cookiePrefix = config('cookie.prefix'); - - // User ID cookie - setcookie( - "{$cookiePrefix}id", - $user->id, - time() + 604800 - ); - - // Session ID cookie - setcookie( - "{$cookiePrefix}session", - $session->key, - time() + 604800 - ); + setcookie("{$cookiePrefix}id", $user->id, time() + 604800); + setcookie("{$cookiePrefix}session", $session->key, time() + 604800); $this->touchRateLimit($user->id, true); - $redirect = $user->lastOnline ? ($_REQUEST['redirect'] ?? route('main.index')) : route('info.welcome'); + $msg = ['error' => null]; - $message = 'Welcome' . ($user->lastOnline ? ' back' : '') . '!'; + if (!$user->lastOnline) { + $msg['go'] = route('info.welcome'); + } - return view('global/information', compact('message', 'redirect')); + return $this->json($msg); } /** @@ -247,7 +223,7 @@ class AuthController extends Controller } // Return true with a specific message if needed - $redirect = route('auth.login'); + $redirect = route('main.index'); $message = 'Your registration went through!'; $message .= $requireActive ? ' An activation e-mail has been sent.' : ' Welcome to ' . config('general.name') . '!'; @@ -294,7 +270,7 @@ class AuthController extends Controller ->where('user_id', $userId) ->update(['user_activated' => 1]); - $redirect = route('auth.login'); + $redirect = route('main.index'); $message = "Your account is activated, welcome to " . config('general.name') . "!"; return view('global/information', compact('message', 'redirect')); } @@ -341,7 +317,7 @@ class AuthController extends Controller // Send activation e-mail to user $this->sendActivationMail($user); - $redirect = route('auth.login'); + $redirect = route('main.index'); $message = "Sent the e-mail! Make sure to check your spam folder as well!"; return view('global/information', compact('message', 'redirect')); } @@ -400,7 +376,7 @@ class AuthController extends Controller $user->setPassword($password); $message = "Changed your password! You may now log in."; - $redirect = route('auth.login'); + $redirect = route('main.index'); } else { // Send the e-mail $this->sendPasswordMail($user); diff --git a/app/CurrentSession.php b/app/CurrentSession.php index 29b6fe2..d8fd259 100644 --- a/app/CurrentSession.php +++ b/app/CurrentSession.php @@ -74,8 +74,8 @@ class CurrentSession * @param int $length * @return Session */ - public static function create(int $user, string $ip, string $country, string $agent = null, bool $remember = false, int $length = 604800) + public static function create(int $user, string $ip, string $country, string $agent = null, int $length = 604800) { - return Session::create($user, $ip, $country, $agent, $remember, $length); + return Session::create($user, $ip, $country, $agent, $length); } } diff --git a/app/Session.php b/app/Session.php index 1b8cdea..c92d319 100644 --- a/app/Session.php +++ b/app/Session.php @@ -61,12 +61,6 @@ class Session */ public $expire = 0; - /** - * Whether to extend the session's lifetime. - * @var bool - */ - public $remember = false; - /** * Constructor, $id can be a number or the secret key. * @param mixed $id @@ -92,7 +86,6 @@ class Session $this->key = $data->session_key; $this->start = intval($data->session_start); $this->expire = intval($data->session_expire); - $this->remember = boolval($data->session_remember); } } @@ -102,11 +95,10 @@ class Session * @param string $ip * @param string $country * @param string $agent - * @param bool $remember * @param int $length * @return Session */ - public static function create(int $user, string $ip, string $country, string $agent = null, bool $remember = false, int $length = 604800) + public static function create(int $user, string $ip, string $country, string $agent = null, int $length = 604800) { $start = time(); $key = bin2hex(random_bytes(64)); @@ -119,7 +111,6 @@ class Session 'session_key' => $key, 'session_start' => $start, 'session_expire' => $start + $length, - 'session_remember' => $remember ? 1 : 0, 'session_country' => $country, ]); @@ -168,14 +159,10 @@ class Session good thing is i can probably do CIDR based checking */ } - // If the remember flag is set extend the session time - if ($session->session_remember) { - DB::table('sessions') - ->where('session_id', $session->session_id) - ->update(['session_expire' => time() + 604800]); - } + DB::table('sessions') + ->where('session_id', $session->session_id) + ->update(['session_expire' => time() + 604800]); - // Return 2 if the remember flag is set and return 1 if not return true; } diff --git a/database/2013_01_27_221444_base_tables.php b/database/2013_01_27_221444_base_tables.php index e4505f9..d6ab89b 100644 --- a/database/2013_01_27_221444_base_tables.php +++ b/database/2013_01_27_221444_base_tables.php @@ -347,10 +347,6 @@ class BaseTables extends Migration $table->integer('session_expire') ->unsigned(); - - $table->tinyInteger('session_remember') - ->unsigned() - ->default(0); }); $schema->create('topics', function (Blueprint $table) { diff --git a/resources/assets/less/yuuno/bem/header-login.less b/resources/assets/less/yuuno/bem/header-login.less index d76aaba..9a11c0a 100644 --- a/resources/assets/less/yuuno/bem/header-login.less +++ b/resources/assets/less/yuuno/bem/header-login.less @@ -1,12 +1,17 @@ -.header-login { - background: rgba(211, 191, 255, .8); - border: 1px solid #9475B2; +.header-login-container { + background: #A586C3; box-shadow: 0 0 3px #8364A1; - text-align: center; +} + +.header-login { max-width: 1024px; - margin: 10px auto 0; - padding: 6px 3px; - border-radius: 3px; + padding: 6px 4px; + margin: 0 auto; + text-align: left; + + display: flex; + justify-content: space-between; + align-items: center; &__text { width: auto !important; @@ -16,17 +21,43 @@ &__button { margin: 0 !important; padding: 2px 8px !important; + + &--small { + font-size: .9em !important; + padding: 1px 8px !important; + } } - &__label { - font-family: @cute-font; - font-weight: 100; - font-size: 15px; + &__sub--buttons { + text-align: right; } - @media (max-width: 640px) { - &__label { - display: block; + @media (max-width: 1064px) { + align-items: flex-start; + + &__text { + margin-bottom: 2px; + } + + &__button--small { + margin-bottom: 2px !important; + display: flex !important; + justify-content: space-between; + align-items: center; + } + + &__sub { + display: flex; + flex-direction: column; + padding: 0 1px; + + &--form { + flex-grow: 1; + } + + &--buttons { + width: 150px; + } } } } diff --git a/resources/assets/less/yuuno/bem/profile.less b/resources/assets/less/yuuno/bem/profile.less index 9db8e36..91141f6 100644 --- a/resources/assets/less/yuuno/bem/profile.less +++ b/resources/assets/less/yuuno/bem/profile.less @@ -17,10 +17,12 @@ display: flex; align-items: center; - // hackjob - pointer-events: none; - position: relative; - top: -100%; + &:not(:first-child) { + // hackjob + pointer-events: none; + position: relative; + top: -100%; + } > * { pointer-events: auto; diff --git a/resources/assets/less/yuuno/bem/uploader.less b/resources/assets/less/yuuno/bem/uploader.less index 0aad219..54c2b1f 100644 --- a/resources/assets/less/yuuno/bem/uploader.less +++ b/resources/assets/less/yuuno/bem/uploader.less @@ -7,6 +7,7 @@ font-size: 3em; line-height: 1.4em; transition: background .2s; + cursor: pointer; &:hover { background: fade(#000, 50%); diff --git a/resources/views/aitemu/master.twig b/resources/views/aitemu/master.twig index f6db108..2c7cc9b 100644 --- a/resources/views/aitemu/master.twig +++ b/resources/views/aitemu/master.twig @@ -33,7 +33,7 @@
{% else %} - +
login
diff --git a/resources/views/aitemu/meta/index.twig b/resources/views/aitemu/meta/index.twig index 7096da8..2b809e6 100644 --- a/resources/views/aitemu/meta/index.twig +++ b/resources/views/aitemu/meta/index.twig @@ -9,7 +9,7 @@
register - login + login

Welcome to my humble abode, it doesn't look like much but if you like rectangles this is the place for you.

diff --git a/resources/views/yuuno/auth/login.twig b/resources/views/yuuno/auth/login.twig deleted file mode 100644 index a9b9f4c..0000000 --- a/resources/views/yuuno/auth/login.twig +++ /dev/null @@ -1,36 +0,0 @@ -{% extends 'master.twig' %} - -{% set title = 'Login' %} - -{% block content %} -
-
- Login -
-
- - - - - - -
-
-{% endblock %} diff --git a/resources/views/yuuno/auth/register.twig b/resources/views/yuuno/auth/register.twig index 333ebe3..2586aa7 100644 --- a/resources/views/yuuno/auth/register.twig +++ b/resources/views/yuuno/auth/register.twig @@ -30,7 +30,8 @@
By creating an account you agree to the Terms of Service.
- You are only allowed to make a single account. + You are only allowed to make a single account.
+ Didn't get your activation e-mail? Click here to resend it!
{% endif %} diff --git a/resources/views/yuuno/auth/resetpassword.twig b/resources/views/yuuno/auth/resetpassword.twig index 4110ce2..783ead4 100644 --- a/resources/views/yuuno/auth/resetpassword.twig +++ b/resources/views/yuuno/auth/resetpassword.twig @@ -17,7 +17,7 @@ {% else %}
Contact us if you lost access to your e-mail address! diff --git a/resources/views/yuuno/master.twig b/resources/views/yuuno/master.twig index 27a8a83..f1eeacf 100644 --- a/resources/views/yuuno/master.twig +++ b/resources/views/yuuno/master.twig @@ -62,40 +62,69 @@ {% endif %} - {% else %} - - {% endif %}
+ + {% if user.id == 0 %} +
+
+ + +
+
+ + + {% endif %} +
- {% if not user.isActive and server['REQUEST_URI'] != route('auth.login') %} -
-
- - - - - -
-
- {% endif %} - {% if user.restricted %}

Your account is currently in restricted mode!

diff --git a/resources/views/yuuno/user/profile.twig b/resources/views/yuuno/user/profile.twig index 5f9f8f0..e590362 100644 --- a/resources/views/yuuno/user/profile.twig +++ b/resources/views/yuuno/user/profile.twig @@ -186,14 +186,18 @@
- + {% if (user.id == profile.id and not user.restricted and user.activated and user.perms.changeHeader) or user.perms.manageProfileImages %} + + {% endif %}
- + {% if (user.id == profile.id and not user.restricted and user.activated and user.perms.changeAvatar) or user.perms.manageProfileImages %} + + {% endif %}

{{ profile.username }}