mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
Update SpaController, persist web language changes
This commit is contained in:
parent
aed570b3f6
commit
7bc684e5d1
2 changed files with 21 additions and 0 deletions
|
@ -9,6 +9,7 @@ use League\CommonMark\CommonMarkConverter;
|
|||
use App\Services\AccountService;
|
||||
use App\Services\StatusService;
|
||||
use App\Services\SnowflakeService;
|
||||
use App\Util\Localization\Localization;
|
||||
|
||||
class SpaController extends Controller
|
||||
{
|
||||
|
@ -68,6 +69,25 @@ class SpaController extends Controller
|
|||
return redirect('404');
|
||||
}
|
||||
|
||||
public function updateLanguage(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'v' => 'required|in:0.1,0.2',
|
||||
'l' => 'required|alpha_dash|max:5'
|
||||
]);
|
||||
|
||||
$lang = $request->input('l');
|
||||
$user = $request->user();
|
||||
|
||||
abort_if(!in_array($lang, Localization::languages()), 400);
|
||||
|
||||
$user->language = $lang;
|
||||
$user->save();
|
||||
session()->put('locale', $lang);
|
||||
|
||||
return ['language' => $lang];
|
||||
}
|
||||
|
||||
public function getPrivacy()
|
||||
{
|
||||
$body = $this->markdownToHtml('views/page/privacy.md');
|
||||
|
|
|
@ -210,6 +210,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
});
|
||||
|
||||
Route::get('discover/accounts/popular', 'Api\ApiV1Controller@discoverAccountsPopular');
|
||||
Route::post('web/change-language.json', 'SpaController@updateLanguage');
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'local'], function () {
|
||||
|
|
Loading…
Reference in a new issue