fix minimal length of password
This commit is contained in:
parent
5efd875b06
commit
f0532dcc6c
|
|
@ -22,23 +22,16 @@ class AuthController extends Controller
|
||||||
public function handleLogin(Request $request)
|
public function handleLogin(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'email' => 'sometimes|required|email',
|
'identification' => 'required',
|
||||||
'username' => 'sometimes|required|username',
|
'password' => 'required|min:6|max:16'
|
||||||
'password' => 'required|min:8|max:16'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($request->has('email')) {
|
$identification = $request->input('identification');
|
||||||
$auth_type = "email";
|
|
||||||
} elseif ($request->has('username')) {
|
$auth_type = (validate($request->input('identification'), 'email')) ? "email" : "username";
|
||||||
$auth_type = "username";
|
|
||||||
} else {
|
|
||||||
return json(trans('auth.validation.identification'), 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
// instantiate user
|
// instantiate user
|
||||||
$user = ($auth_type == 'email') ?
|
$user = new User(null, [$auth_type => $identification]);
|
||||||
new User(null, ['email' => $request->input('email')]) :
|
|
||||||
new User(null, ['username' => $request->input('username')]);
|
|
||||||
|
|
||||||
if (session('login_fails', 0) > 3) {
|
if (session('login_fails', 0) > 3) {
|
||||||
if (strtolower($request->input('captcha')) != strtolower(session('phrase')))
|
if (strtolower($request->input('captcha')) != strtolower(session('phrase')))
|
||||||
|
|
@ -59,18 +52,13 @@ class AuthController extends Controller
|
||||||
setcookie('uid', $user->uid, time()+$time, '/');
|
setcookie('uid', $user->uid, time()+$time, '/');
|
||||||
setcookie('token', $user->getToken(), time()+$time, '/');
|
setcookie('token', $user->getToken(), time()+$time, '/');
|
||||||
|
|
||||||
return json([
|
return json(trans('auth.login.success'), 0, [
|
||||||
'errno' => 0,
|
|
||||||
'msg' => trans('auth.login.success'),
|
|
||||||
'token' => $user->getToken()
|
'token' => $user->getToken()
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$fails = session('login_fails', 0);
|
Session::put('login_fails', session('login_fails', 0) + 1);
|
||||||
Session::put('login_fails', $fails + 1);
|
|
||||||
|
|
||||||
return json([
|
return json(trans('auth.validation.password'), 1, [
|
||||||
'errno' => 1,
|
|
||||||
'msg' => trans('auth.validation.password'),
|
|
||||||
'login_fails' => session('login_fails')
|
'login_fails' => session('login_fails')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -232,3 +232,19 @@ if (! function_exists('menv')) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! function_exists('validate')) {
|
||||||
|
|
||||||
|
function validate($value, $type)
|
||||||
|
{
|
||||||
|
switch ($type) {
|
||||||
|
case 'email':
|
||||||
|
return (bool) filter_var($value, FILTER_VALIDATE_EMAIL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
# code...
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* @Author: printempw
|
* @Author: printempw
|
||||||
* @Date: 2016-07-17 10:54:22
|
* @Date: 2016-07-17 10:54:22
|
||||||
* @Last Modified by: printempw
|
* @Last Modified by: prpr
|
||||||
* @Last Modified time: 2016-09-15 10:09:52
|
* @Last Modified time: 2016-10-02 20:27:13
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
@ -21,22 +21,15 @@ function freshCaptcha() {
|
||||||
var login_fails = 0;
|
var login_fails = 0;
|
||||||
|
|
||||||
$('#login-button').click(function() {
|
$('#login-button').click(function() {
|
||||||
var data = new Object();
|
var data = new Object();
|
||||||
var email_or_uname = $('#email_or_username').val();
|
|
||||||
|
|
||||||
if (/\S+@\S+\.\S+/.test($('#email_or_username').val())) {
|
|
||||||
data.email = email_or_uname;
|
|
||||||
} else {
|
|
||||||
data.username = email_or_uname;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
data.identification = $('#identification').val();
|
||||||
data.password = $('#password').val();
|
data.password = $('#password').val();
|
||||||
data.keep = $('#keep').prop('checked') ? true : false;
|
data.keep = $('#keep').prop('checked') ? true : false;
|
||||||
|
|
||||||
if (email_or_uname == "") {
|
if (data.identification == "") {
|
||||||
showMsg(trans('auth.emptyIdentification'));
|
showMsg(trans('auth.emptyIdentification'));
|
||||||
$('#email_or_username').focus();
|
$('#identification').focus();
|
||||||
// check valid email address
|
|
||||||
} else if (data.password == "") {
|
} else if (data.password == "") {
|
||||||
showMsg(trans('auth.emptyPassword'));
|
showMsg(trans('auth.emptyPassword'));
|
||||||
$('#password').focus();
|
$('#password').focus();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
general:
|
general:
|
||||||
filter: Filter
|
filter: Filter
|
||||||
my-upload: My Uploaded
|
my-upload: Uploaded by Me
|
||||||
sort: Sort
|
sort: Sort
|
||||||
search-textures: Search For Textures
|
search-textures: Search For Textures
|
||||||
upload-new-skin: Upload New Skin
|
upload-new-skin: Upload New Skin
|
||||||
|
|
|
||||||
|
|
@ -75,10 +75,13 @@ url: ':attribute 格式不正确。'
|
||||||
|
|
||||||
custom:
|
custom:
|
||||||
attribute-name: { rule-name: custom-message }
|
attribute-name: { rule-name: custom-message }
|
||||||
|
identification:
|
||||||
|
required: 邮箱或角色名格式错误
|
||||||
|
|
||||||
attributes:
|
attributes:
|
||||||
name: 名称
|
name: 名称
|
||||||
username: 用户名
|
username: 用户名
|
||||||
|
identification: 邮箱或角色名
|
||||||
nickname: 昵称
|
nickname: 昵称
|
||||||
player_name: 角色名
|
player_name: 角色名
|
||||||
email: 邮箱
|
email: 邮箱
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<form id="login-form">
|
<form id="login-form">
|
||||||
<div class="form-group has-feedback">
|
<div class="form-group has-feedback">
|
||||||
<input id="email_or_username" type="email" class="form-control" placeholder="{{ trans('auth.identification') }}">
|
<input id="identification" type="email" class="form-control" placeholder="{{ trans('auth.identification') }}">
|
||||||
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
|
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group has-feedback">
|
<div class="form-group has-feedback">
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ switch ($step) {
|
||||||
$password = $_POST['password'];
|
$password = $_POST['password'];
|
||||||
$sitename = isset($_POST['sitename']) ? $_POST['sitename'] : "Blessing Skin Server";
|
$sitename = isset($_POST['sitename']) ? $_POST['sitename'] : "Blessing Skin Server";
|
||||||
|
|
||||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
if (validate($email, 'email')) {
|
||||||
if (!check_password($password)) {
|
if (!check_password($password)) {
|
||||||
redirect_to('index.php?step=2', '无效的密码。密码长度应该大于 8 并小于 16。');
|
redirect_to('index.php?step=2', '无效的密码。密码长度应该大于 8 并小于 16。');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user