datatable.directory codebase
				https://datatable.directory/
			
			
		
			Você não pode selecionar mais de 25 tópicos
			Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
		
		
		
		
		
			
		
			
				
					
					
						
							80 linhas
						
					
					
						
							1.9 KiB
						
					
					
				
			
		
		
	
	
							80 linhas
						
					
					
						
							1.9 KiB
						
					
					
				| <?php
 | |
| 
 | |
| 
 | |
| namespace App\Http\Controllers;
 | |
| 
 | |
| 
 | |
| use App\Models\EmailConfirmation;
 | |
| 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)
 | |
|     {
 | |
|         $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],
 | |
|         ]);
 | |
| 
 | |
|         $user = user();
 | |
| 
 | |
|         if ($input->email != $user->email) {
 | |
|             $confirmation = EmailConfirmation::create([
 | |
|                 'user_id' => $user->id,
 | |
|                 'email' => $input->email,
 | |
|                 'token' => Str::random(60),
 | |
|             ]);
 | |
| 
 | |
|             flash()->warning("New e-mail confirmation sent to $input->email.")->important();
 | |
| 
 | |
|             // TODO send the e-mail
 | |
| 
 | |
|             unset($input->email);
 | |
|         }
 | |
| 
 | |
|         $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'));
 | |
|     }
 | |
| }
 | |
| 
 |