datatable.directory codebase
				https://datatable.directory/
			
			
		
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							76 lines
						
					
					
						
							1.8 KiB
						
					
					
				
			
		
		
	
	
							76 lines
						
					
					
						
							1.8 KiB
						
					
					
				<?php
 | 
						|
 | 
						|
 | 
						|
namespace App\Http\Controllers;
 | 
						|
 | 
						|
 | 
						|
use App\Models\EmailConfirmation;
 | 
						|
use App\Models\User;
 | 
						|
use Hash;
 | 
						|
use Illuminate\Http\Request;
 | 
						|
use Illuminate\Validation\Rule;
 | 
						|
use MightyPork\Utils\Str;
 | 
						|
 | 
						|
/**
 | 
						|
 * Account settings
 | 
						|
 */
 | 
						|
class AccountController extends Controller
 | 
						|
{
 | 
						|
    public function editAccount()
 | 
						|
    {
 | 
						|
        return view('profile.edit-account', ['user' => user()]);
 | 
						|
    }
 | 
						|
 | 
						|
    public function storeAccount(Request $request)
 | 
						|
    {
 | 
						|
        /** @var User $user */
 | 
						|
        $user = user();
 | 
						|
 | 
						|
        $input = $this->validate($request, [
 | 
						|
            'name' => [
 | 
						|
                'required',
 | 
						|
                VALI_NAME,
 | 
						|
                Rule::unique('users')->ignoreModel($user),
 | 
						|
            ],
 | 
						|
            'email' => [
 | 
						|
                'required',
 | 
						|
                VALI_EMAIL,
 | 
						|
                Rule::unique('users')->ignoreModel($user),
 | 
						|
            ],
 | 
						|
            'new_password' => ['nullable', 'confirmed', VALI_PASSWORD],
 | 
						|
        ]);
 | 
						|
 | 
						|
        if ($input->email != $user->email) {
 | 
						|
            $user->sendEmailConfirmationLink($input->email);
 | 
						|
 | 
						|
            flash()->warning("E-mail confirmation sent to $input->email.")->important();
 | 
						|
 | 
						|
            unset($input->email); // prevent updating the field in the model via fill
 | 
						|
        }
 | 
						|
 | 
						|
        $user->fill($input->all());
 | 
						|
 | 
						|
        if ($input->has('new_password')) {
 | 
						|
            $user->password = Hash::make($input->new_password);
 | 
						|
 | 
						|
            flash()->warning('Password changed');
 | 
						|
        }
 | 
						|
 | 
						|
        $user->save();
 | 
						|
 | 
						|
        flash()->success('Settings saved');
 | 
						|
 | 
						|
        return back();
 | 
						|
    }
 | 
						|
 | 
						|
    public function forgetSocialLogin($id)
 | 
						|
    {
 | 
						|
        $identity = user()->socialIdentities()->where('id', $id)->first();
 | 
						|
        if (null === $identity) {
 | 
						|
            abort(404, "No such identity");
 | 
						|
        }
 | 
						|
 | 
						|
        $identity->delete();
 | 
						|
        return redirect(route('profile.manage-oauth'));
 | 
						|
    }
 | 
						|
}
 | 
						|
 |