mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-30 16:30:45 +00:00
Update SettingsController
This commit is contained in:
parent
230f935262
commit
a2d4b7c1fc
1 changed files with 29 additions and 8 deletions
|
@ -3,7 +3,7 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\{AccountLog, Media, Profile, User};
|
use App\{AccountLog, EmailVerification, Media, Profile, User};
|
||||||
use Auth, DB;
|
use Auth, DB;
|
||||||
use App\Util\Lexer\PrettyNumber;
|
use App\Util\Lexer\PrettyNumber;
|
||||||
|
|
||||||
|
@ -31,24 +31,45 @@ class SettingsController extends Controller
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'name' => 'required|string|max:30',
|
'name' => 'required|string|max:30',
|
||||||
'bio' => 'nullable|string|max:125'
|
'bio' => 'nullable|string|max:125',
|
||||||
|
'website' => 'nullable|url',
|
||||||
|
'email' => 'nullable|email'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$changes = false;
|
$changes = false;
|
||||||
$name = $request->input('name');
|
$name = $request->input('name');
|
||||||
$bio = $request->input('bio');
|
$bio = $request->input('bio');
|
||||||
|
$website = $request->input('website');
|
||||||
|
$email = $request->input('email');
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$profile = $user->profile;
|
$profile = $user->profile;
|
||||||
|
|
||||||
if($profile->name != $name) {
|
|
||||||
|
if($user->email != $email) {
|
||||||
$changes = true;
|
$changes = true;
|
||||||
$user->name = $name;
|
$user->email = $email;
|
||||||
$profile->name = $name;
|
$user->email_verified_at = null;
|
||||||
|
// Prevent old verifications from working
|
||||||
|
EmailVerification::whereUserId($user->id)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($profile->bio != $bio) {
|
// Only allow email to be updated if not yet verified
|
||||||
$changes = true;
|
if(!$changes && $user->email_verified_at) {
|
||||||
$profile->bio = $bio;
|
if($profile->name != $name) {
|
||||||
|
$changes = true;
|
||||||
|
$user->name = $name;
|
||||||
|
$profile->name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($profile->website != $website) {
|
||||||
|
$changes = true;
|
||||||
|
$profile->website = $website;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($profile->bio != $bio) {
|
||||||
|
$changes = true;
|
||||||
|
$profile->bio = $bio;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($changes === true) {
|
if($changes === true) {
|
||||||
|
|
Loading…
Reference in a new issue