<?php

namespace App\Http\Controllers\UserAuth;

use App\Http\Controllers\Controller;
use App\Mail\ConfirmationMail;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;

class ChangeEmailVerificationController extends Controller
{
    
    public function index(){

        if(session()->get('user_data') != ''){
            return view('Dashboard.User.ChangeEmail');
        }else{
            return redirect('/');
        }

    }

    public function store(Request $request){

        session()->put('user_data.email' , $request->email);
        $name = session()->get('user_data.name');
        $generator = session()->get('verify');

       Mail::send(new ConfirmationMail($name , $generator , $request->email));
        return redirect('/Servlet/VerifyEmail.py?NewEmail=add');
    }

}
