mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +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;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\{AccountLog, Media, Profile, User};
|
||||
use App\{AccountLog, EmailVerification, Media, Profile, User};
|
||||
use Auth, DB;
|
||||
use App\Util\Lexer\PrettyNumber;
|
||||
|
||||
|
@ -31,24 +31,45 @@ class SettingsController extends Controller
|
|||
{
|
||||
$this->validate($request, [
|
||||
'name' => 'required|string|max:30',
|
||||
'bio' => 'nullable|string|max:125'
|
||||
'bio' => 'nullable|string|max:125',
|
||||
'website' => 'nullable|url',
|
||||
'email' => 'nullable|email'
|
||||
]);
|
||||
|
||||
$changes = false;
|
||||
$name = $request->input('name');
|
||||
$bio = $request->input('bio');
|
||||
$website = $request->input('website');
|
||||
$email = $request->input('email');
|
||||
$user = Auth::user();
|
||||
$profile = $user->profile;
|
||||
|
||||
if($profile->name != $name) {
|
||||
|
||||
if($user->email != $email) {
|
||||
$changes = true;
|
||||
$user->name = $name;
|
||||
$profile->name = $name;
|
||||
$user->email = $email;
|
||||
$user->email_verified_at = null;
|
||||
// Prevent old verifications from working
|
||||
EmailVerification::whereUserId($user->id)->delete();
|
||||
}
|
||||
|
||||
if($profile->bio != $bio) {
|
||||
$changes = true;
|
||||
$profile->bio = $bio;
|
||||
// Only allow email to be updated if not yet verified
|
||||
if(!$changes && $user->email_verified_at) {
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue