mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-15 06:09:58 +08:00
add menu for switching languages
This commit is contained in:
parent
0fe9cf19b4
commit
41f24b9a3a
@ -32,7 +32,7 @@ class AuthController extends Controller
|
||||
} elseif ($request->has('username')) {
|
||||
$auth_type = "username";
|
||||
} else {
|
||||
return json('邮箱或角色名格式错误', 3);
|
||||
return json(trans('auth.validation.identification'), 3);
|
||||
}
|
||||
|
||||
// instantiate user
|
||||
@ -42,11 +42,11 @@ class AuthController extends Controller
|
||||
|
||||
if (session('login_fails', 0) > 3) {
|
||||
if (strtolower($request->input('captcha')) != strtolower(session('phrase')))
|
||||
return json('验证码填写错误', 1);
|
||||
return json(trans('auth.validation.captcha'), 1);
|
||||
}
|
||||
|
||||
if (!$user->is_registered) {
|
||||
return json('用户不存在哦', 2);
|
||||
return json(trans('auth.validation.user'), 2);
|
||||
} else {
|
||||
if ($user->checkPasswd($request->input('password'))) {
|
||||
Session::forget('login_fails');
|
||||
@ -61,7 +61,7 @@ class AuthController extends Controller
|
||||
|
||||
return json([
|
||||
'errno' => 0,
|
||||
'msg' => '登录成功,欢迎回来~',
|
||||
'msg' => trans('auth.login.success'),
|
||||
'token' => $user->getToken()
|
||||
]);
|
||||
} else {
|
||||
@ -70,7 +70,7 @@ class AuthController extends Controller
|
||||
|
||||
return json([
|
||||
'errno' => 1,
|
||||
'msg' => '邮箱或密码不对哦~',
|
||||
'msg' => trans('auth.login.password'),
|
||||
'login_fails' => session('login_fails')
|
||||
]);
|
||||
}
|
||||
@ -85,9 +85,9 @@ class AuthController extends Controller
|
||||
|
||||
Session::flush();
|
||||
|
||||
return json('登出成功~', 0);
|
||||
return json(trans('auth.logout.success'), 0);
|
||||
} else {
|
||||
return json('并没有有效的 session', 1);
|
||||
return json(trans('auth.logout.failed'), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,14 +96,14 @@ class AuthController extends Controller
|
||||
if (Option::get('user_can_register') == 1) {
|
||||
return view('auth.register');
|
||||
} else {
|
||||
throw new PrettyPageException('残念。。本皮肤站已经关闭注册咯 QAQ', 7);
|
||||
throw new PrettyPageException(trans('auth.register.close'), 7);
|
||||
}
|
||||
}
|
||||
|
||||
public function handleRegister(Request $request)
|
||||
{
|
||||
if (strtolower($request->input('captcha')) != strtolower(session('phrase')))
|
||||
return json('验证码填写错误', 1);
|
||||
return json(trans('auth.validation.captcha'), 1);
|
||||
|
||||
$this->validate($request, [
|
||||
'email' => 'required|email',
|
||||
@ -131,18 +131,18 @@ class AuthController extends Controller
|
||||
|
||||
return json([
|
||||
'errno' => 0,
|
||||
'msg' => '注册成功,正在跳转~',
|
||||
'msg' => trans('auth.register.success'),
|
||||
'token' => $user->getToken()
|
||||
]);
|
||||
|
||||
} else {
|
||||
return json('你最多只能注册 '.Option::get('regs_per_ip').' 个账户哦', 7);
|
||||
return json(trans('auth.register.max', ['regs' => Option::get('regs_per_ip')]), 7);
|
||||
}
|
||||
} else {
|
||||
return json('残念。。本皮肤站已经关闭注册咯 QAQ', 7);
|
||||
return json(trans('auth.register.close'), 7);
|
||||
}
|
||||
} else {
|
||||
return json('这个邮箱已经注册过啦,换一个吧', 5);
|
||||
return json(trans('auth.register.registered'), 5);
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,25 +151,25 @@ class AuthController extends Controller
|
||||
if (config('mail.host') != "") {
|
||||
return view('auth.forgot');
|
||||
} else {
|
||||
throw new PrettyPageException('本站已关闭重置密码功能', 8);
|
||||
throw new PrettyPageException(trans('auth.forgot.close'), 8);
|
||||
}
|
||||
}
|
||||
|
||||
public function handleForgot(Request $request)
|
||||
{
|
||||
if (strtolower($request->input('captcha')) != strtolower(session('phrase')))
|
||||
return json('验证码填写错误', 1);
|
||||
return json(trans('auth.validation.captcha'), 1);
|
||||
|
||||
if (config('mail.host') == "")
|
||||
return json('本站已关闭重置密码功能', 1);
|
||||
return json(trans('auth.forgot.close'), 1);
|
||||
|
||||
if (Session::has('last_mail_time') && (time() - session('last_mail_time')) < 60)
|
||||
return json('你邮件发送得太频繁啦,过 60 秒后再点发送吧', 1);
|
||||
return json(trans('auth.forgot.frequent-mail'), 1);
|
||||
|
||||
$user = new User(null, ['email' => $request->input('email')]);
|
||||
|
||||
if (!$user->is_registered)
|
||||
return json('该邮箱尚未注册', 1);
|
||||
return json(trans('auth.forgot.unregistered'), 1);
|
||||
|
||||
$uid = $user->uid;
|
||||
$token = base64_encode($user->getToken().substr(time(), 4, 6).Utils::generateRndString(16));
|
||||
@ -181,15 +181,15 @@ class AuthController extends Controller
|
||||
$site_name = Option::get('site_name');
|
||||
|
||||
$m->from(config('mail.username'), $site_name);
|
||||
$m->to($request->input('email'))->subject("重置您在 $site_name 上的账户密码");
|
||||
$m->to($request->input('email'))->subject(trans('auth.mail.title', ['sitename' => $site_name]));
|
||||
});
|
||||
} catch(\Exception $e) {
|
||||
return json('邮件发送失败,详细信息:'.$e->getMessage(), 2);
|
||||
return json(trans('auth.mail.failed', ['msg' => $e->getMessage()]), 2);
|
||||
}
|
||||
|
||||
Session::put('last_mail_time', time());
|
||||
|
||||
return json('邮件已发送,一小时内有效,请注意查收.', 0);
|
||||
return json(trans('auth.mail.success'), 0);
|
||||
}
|
||||
|
||||
public function reset()
|
||||
@ -197,24 +197,24 @@ class AuthController extends Controller
|
||||
if (isset($_GET['uid']) && isset($_GET['token'])) {
|
||||
$user = new User($_GET['uid']);
|
||||
if (!$user->is_registered)
|
||||
return redirect('auth/forgot')->with('msg', '无效的链接');
|
||||
return redirect('auth/forgot')->with('msg', trans('auth.reset.invalid'));
|
||||
|
||||
$token = substr(base64_decode($_GET['token']), 0, -22);
|
||||
|
||||
if ($user->getToken() != $token) {
|
||||
return redirect('auth/forgot')->with('msg', '无效的链接');
|
||||
return redirect('auth/forgot')->with('msg', trans('auth.reset.invalid'));
|
||||
}
|
||||
|
||||
$timestamp = substr(base64_decode($_GET['token']), strlen($token), 6);
|
||||
|
||||
// more than 1 hour
|
||||
if ((substr(time(), 4, 6) - $timestamp) > 3600) {
|
||||
return redirect('auth/forgot')->with('msg', '链接已过期');
|
||||
return redirect('auth/forgot')->with('msg', trans('auth.reset.expired'));
|
||||
}
|
||||
|
||||
return view('auth.reset')->with('user', $user);
|
||||
} else {
|
||||
return redirect('auth/login')->with('msg', '非法访问');
|
||||
return redirect('auth/login')->with('msg', trans('auth.check.anonymous'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ class AuthController extends Controller
|
||||
|
||||
$user->changePasswd($request->input('password'));
|
||||
|
||||
return json('密码重置成功', 0);
|
||||
return json(trans('auth.reset.success'), 0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\UserModel;
|
||||
use App\Exceptions\PrettyPageException;
|
||||
use View;
|
||||
use Http;
|
||||
use Session;
|
||||
use App\Models\User;
|
||||
use App\Models\UserModel;
|
||||
use App\Exceptions\PrettyPageException;
|
||||
|
||||
class CheckAuthenticated
|
||||
{
|
||||
@ -17,7 +17,7 @@ class CheckAuthenticated
|
||||
$user = new User(session('uid'));
|
||||
|
||||
if (session('token') != $user->getToken())
|
||||
return redirect('auth/login')->with('msg', '无效的 token,请重新登录');
|
||||
return redirect('auth/login')->with('msg', trans('auth.check.token'));
|
||||
|
||||
if ($user->getPermission() == "-1") {
|
||||
// delete cookies
|
||||
@ -26,7 +26,7 @@ class CheckAuthenticated
|
||||
|
||||
Session::flush();
|
||||
|
||||
throw new PrettyPageException('你已经被本站封禁啦,请联系管理员解决', 5);
|
||||
throw new PrettyPageException(trans('auth.check.banned'), 5);
|
||||
}
|
||||
|
||||
// ask for filling email
|
||||
@ -41,10 +41,10 @@ class CheckAuthenticated
|
||||
|
||||
return $next($request);
|
||||
} else {
|
||||
echo View::make('auth.bind')->with('msg', '该邮箱已被占用');
|
||||
echo View::make('auth.bind')->with('msg', trans('auth.validation.email'));
|
||||
}
|
||||
} else {
|
||||
echo View::make('auth.bind')->with('msg', '邮箱格式错误');
|
||||
echo View::make('auth.bind')->with('msg', trans('auth.bind.registered'));
|
||||
}
|
||||
exit;
|
||||
}
|
||||
@ -57,7 +57,7 @@ class CheckAuthenticated
|
||||
|
||||
return $next($request);
|
||||
} else {
|
||||
return redirect('auth/login')->with('msg', '非法访问,请先登录');
|
||||
return redirect('auth/login')->with('msg', trans('auth.check.anonymous'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Session;
|
||||
use App;
|
||||
use Session;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class Internationalization
|
||||
{
|
||||
|
@ -9,6 +9,6 @@ return [
|
||||
| Available Languages
|
||||
|
|
||||
*/
|
||||
'zh-CN' => 'Chinese Simplified',
|
||||
'zh-CN' => '简体中文',
|
||||
'en' => 'English'
|
||||
];
|
||||
|
@ -1,34 +1,70 @@
|
||||
login:
|
||||
login: 登录
|
||||
title: 登录
|
||||
button: 登录
|
||||
message: 登录以管理您的角色及皮肤
|
||||
keep: 保持登录状态
|
||||
success: 登录成功,欢迎回来~
|
||||
|
||||
check:
|
||||
anonymous: 非法访问,请先登录
|
||||
banned: 你已经被本站封禁啦,请联系管理员解决
|
||||
token: 无效的 token,请重新登录
|
||||
|
||||
register:
|
||||
register: 注册
|
||||
title: 注册
|
||||
button: 注册
|
||||
message: 欢迎使用 :sitename!
|
||||
nickname-intro: 昵称可使用汉字,不可包含特殊字符
|
||||
repeat-pwd: 重复密码
|
||||
close: 残念。。本皮肤站已经关闭注册咯 QAQ
|
||||
success: 注册成功,正在跳转~
|
||||
max: 你最多只能注册 :regs 个账户哦
|
||||
registered: 这个邮箱已经注册过啦,换一个吧
|
||||
|
||||
forgot:
|
||||
forgot: 重置密码
|
||||
title: 忘记密码
|
||||
button: 发送
|
||||
message: 我们将会向您发送一封验证邮件
|
||||
send: 发送
|
||||
login-link: 我又想起来了
|
||||
close: 本站已关闭重置密码功能
|
||||
frequent-mail: 你邮件发送得太频繁啦,过 60 秒后再点发送吧
|
||||
unregistered: 该邮箱尚未注册
|
||||
|
||||
mail:
|
||||
title: 重置您在 :sitename 上的账户密码
|
||||
success: 邮件已发送,一小时内有效,请注意查收。
|
||||
failed: 邮件发送失败,详细信息::msg
|
||||
message: 您收到这封邮件,是因为在 :sitename 的用户重置密码功能使用了您的地址。
|
||||
ignore: 如果您并没有访问过我们的网站,或没有进行上述操作,请忽略这封邮件。 您不需要退订或进行其他进一步的操作。
|
||||
reset: 重置密码
|
||||
notice: 本邮件由系统自动发送,就算你回复了我们也不会回复你哦
|
||||
|
||||
reset:
|
||||
reset: 重置
|
||||
title: 重置密码
|
||||
button: 重置
|
||||
invalid: 无效的链接
|
||||
expired: 链接已过期
|
||||
message: :username,在这里重置你的密码
|
||||
success: 密码重置成功
|
||||
|
||||
bind:
|
||||
bind: 绑定
|
||||
title: 绑定邮箱
|
||||
button: 绑定
|
||||
message: 你需要绑定邮箱地址以继续使用本站
|
||||
introduction: 邮箱地址仅用于重置密码,我们将不会向您发送任何垃圾邮件
|
||||
registered: 该邮箱已被占用
|
||||
|
||||
|
||||
validation:
|
||||
identification: 邮箱或角色名格式错误
|
||||
email: 邮箱格式错误
|
||||
captcha: 验证码填写错误
|
||||
user: 用户不存在哦
|
||||
password: 邮箱或密码不对哦~
|
||||
|
||||
logout:
|
||||
success: 登出成功~
|
||||
fail: 并没有有效的 session
|
||||
|
||||
nickname: 昵称
|
||||
email: Email
|
||||
|
7
resources/lang/zh-CN/index.yml
Normal file
7
resources/lang/zh-CN/index.yml
Normal file
@ -0,0 +1,7 @@
|
||||
index: 首页
|
||||
skinlib: 皮肤库
|
||||
langs: 语言
|
||||
user-center: 用户中心
|
||||
logout: 登出
|
||||
login: 登录
|
||||
register: 现在注册
|
@ -44,6 +44,17 @@
|
||||
<!-- Navbar Right Menu -->
|
||||
<div class="navbar-custom-menu">
|
||||
<ul class="nav navbar-nav">
|
||||
<!-- Language Menu -->
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-language" aria-hidden="true"></i> {{ trans('index.langs') }} <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
@foreach(config('locales') as $locale => $lang)
|
||||
<li><a href="{{ url('/locale/'.$locale) }}">{{ $lang }}</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</li>
|
||||
<!-- User Account Menu -->
|
||||
<li class="dropdown user user-menu">
|
||||
<!-- Menu Toggle Button -->
|
||||
|
@ -1,6 +1,6 @@
|
||||
@extends('auth.master')
|
||||
|
||||
@section('title', trans('auth.bind.bind'))
|
||||
@section('title', trans('auth.bind.title'))
|
||||
|
||||
@section('content')
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-8"></div>
|
||||
<div class="col-xs-4">
|
||||
<button type="submit" class="btn btn-primary btn-block btn-flat">{{ trans('auth.bind.bind') }}</button>
|
||||
<button type="submit" class="btn btn-primary btn-block btn-flat">{{ trans('auth.bind.button') }}</button>
|
||||
</div><!-- /.col -->
|
||||
</div>
|
||||
</form>
|
||||
|
@ -1,6 +1,6 @@
|
||||
@extends('auth.master')
|
||||
|
||||
@section('title', trans('auth.forgot.forgot'))
|
||||
@section('title', trans('auth.forgot.title'))
|
||||
|
||||
@section('content')
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-xs-4">
|
||||
<button id="forgot-button" class="btn btn-primary btn-block btn-flat">{{ trans('auth.forgot.send') }}</button>
|
||||
<button id="forgot-button" class="btn btn-primary btn-block btn-flat">{{ trans('auth.forgot.button') }}</button>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
@extends('auth.master')
|
||||
|
||||
@section('title', trans('auth.login.login'))
|
||||
@section('title', trans('auth.login.title'))
|
||||
|
||||
@section('content')
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-xs-4">
|
||||
<button id="login-button" class="btn btn-primary btn-block btn-flat">{{ trans('auth.login.login') }}</button>
|
||||
<button id="login-button" class="btn btn-primary btn-block btn-flat">{{ trans('auth.login.button') }}</button>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
@extends('auth.master')
|
||||
|
||||
@section('title', trans('auth.register.register'))
|
||||
@section('title', trans('auth.register.title'))
|
||||
|
||||
@section('content')
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-xs-4">
|
||||
<button id="register-button" class="btn btn-primary btn-block btn-flat">{{ trans('auth.register.register') }}</button>
|
||||
<button id="register-button" class="btn btn-primary btn-block btn-flat">{{ trans('auth.register.button') }}</button>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
@extends('auth.master')
|
||||
|
||||
@section('title', trans('auth.forgot.reset'))
|
||||
@section('title', trans('auth.reset.title'))
|
||||
|
||||
@section('content')
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-xs-4">
|
||||
<button id="reset-button" class="btn btn-primary btn-block btn-flat">{{ trans('auth.reset.reset') }}</button>
|
||||
<button id="reset-button" class="btn btn-primary btn-block btn-flat">{{ trans('auth.reset.button') }}</button>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
|
@ -36,8 +36,19 @@
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse pull-left" id="navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a href="{{ url('/') }}">首页</a></li>
|
||||
<li><a href="{{ url('skinlib') }}">皮肤库</a></li>
|
||||
<li class="active"><a href="{{ url('/') }}">{{ trans('index.index') }}</a></li>
|
||||
<li><a href="{{ url('skinlib') }}">{{ trans('index.skinlib') }}</a></li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-language" aria-hidden="true"></i> {{ trans('index.langs') }} <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
@foreach(config('locales') as $locale => $lang)
|
||||
<li><a href="{{ url('/locale/'.$locale) }}">{{ $lang }}</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div><!-- /.navbar-collapse -->
|
||||
<!-- Navbar Right Menu -->
|
||||
@ -62,10 +73,10 @@
|
||||
<!-- Menu Footer-->
|
||||
<li class="user-footer">
|
||||
<div class="pull-left">
|
||||
<a href="{{ url('user') }}" class="btn btn-default btn-flat">用户中心</a>
|
||||
<a href="{{ url('user') }}" class="btn btn-default btn-flat">{{ trans('index.user-center') }}</a>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a href="javascript:logout();" class="btn btn-default btn-flat">登出</a>
|
||||
<a href="javascript:logout();" class="btn btn-default btn-flat">{{ trans('index.logout') }}</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
@ -73,7 +84,7 @@
|
||||
@else {{-- Anonymous User --}}
|
||||
<!-- User Account Menu -->
|
||||
<li class="dropdown user user-menu">
|
||||
<a href="{{ url('auth/login') }}" class="btn btn-login">登录</a>
|
||||
<a href="{{ url('auth/login') }}" class="btn btn-login">{{ trans('index.login') }}</a>
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
@ -92,9 +103,9 @@
|
||||
</p>
|
||||
<p>
|
||||
@if (is_null($user))
|
||||
<a href="{{ url('auth/register') }}" class="button">现在注册</a>
|
||||
<a href="{{ url('auth/register') }}" class="button">{{ trans('index.register') }}</a>
|
||||
@else
|
||||
<a href="{{ url('user') }}" class="button">用户中心</a>
|
||||
<a href="{{ url('user') }}" class="button">{{ trans('index.user-center') }}</a>
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
|
@ -75,6 +75,18 @@
|
||||
<!-- Navbar Right Menu -->
|
||||
<div class="navbar-custom-menu">
|
||||
<ul class="nav navbar-nav">
|
||||
<!-- Language Menu -->
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-language" aria-hidden="true"></i> {{ trans('index.langs') }} <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
@foreach(config('locales') as $locale => $lang)
|
||||
<li><a href="{{ url('/locale/'.$locale) }}">{{ $lang }}</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li><a href="{{ url('skinlib/upload') }}"><i class="fa fa-upload" aria-hidden="true"></i> 上传新皮肤</a></li>
|
||||
@if (!is_null($user))
|
||||
<!-- User Account Menu -->
|
||||
|
@ -42,6 +42,17 @@
|
||||
<!-- Navbar Right Menu -->
|
||||
<div class="navbar-custom-menu">
|
||||
<ul class="nav navbar-nav">
|
||||
<!-- Language Menu -->
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-language" aria-hidden="true"></i> {{ trans('index.langs') }} <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
@foreach(config('locales') as $locale => $lang)
|
||||
<li><a href="{{ url('/locale/'.$locale) }}">{{ $lang }}</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</li>
|
||||
<!-- User Account Menu -->
|
||||
<li class="dropdown user user-menu">
|
||||
<!-- Menu Toggle Button -->
|
||||
|
Loading…
Reference in New Issue
Block a user