1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-25 09:17:03 +00:00

Update SettingsController, fix bug that prevented instances without email validation to update settings

This commit is contained in:
Daniel Supernault 2018-08-20 20:33:07 -06:00
parent 7e78f63ff5
commit bde671657f
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -44,29 +44,33 @@ class SettingsController extends Controller
$user = Auth::user();
$profile = $user->profile;
$validate = config('pixelfed.enforce_email_verification');
if($user->email != $email) {
$changes = true;
$user->email = $email;
if($validate) {
$user->email_verified_at = null;
// Prevent old verifications from working
EmailVerification::whereUserId($user->id)->delete();
}
}
// Only allow email to be updated if not yet verified
if(!$changes && $user->email_verified_at) {
if(!$validate || !$changes && $user->email_verified_at) {
if($profile->name != $name) {
$changes = true;
$user->name = $name;
$profile->name = $name;
}
if($profile->website != $website) {
if(!$profile->website || $profile->website != $website) {
$changes = true;
$profile->website = $website;
}
if($profile->bio != $bio) {
if(!$profile->bio || !$profile->bio != $bio) {
$changes = true;
$profile->bio = $bio;
}