app/Controllers/Auth/AuthController.php
// This method is called when the user submits the final form
This method is called when the user submits the final form
This method is called when the user submits the final form
public function postCompleteSignUp($request, $response)
  {
    $validation = $this->validator->validate($request, [
      'email' => v::noWhitespace()->notEmpty()->email()->EmailAvailable(),
      'password' => v::noWhitespace()->notEmpty(),
    ]);
    if ($validation->failed()) {
      return $response->withRedirect($this->router->pathFor('auth.completesignup'));
    }
    $usermeta = Usermeta::orderBy('id', 'desc')->first();
    $user = User::create([
      'email' => $request->getParam('email'),
      'password' => password_hash($request->getParam('password'), PASSWORD_DEFAULT),
      'usermeta_id'=> $usermeta->id,
    ]);
    $this->flash->addMessage('success', 'You have been successfully signed up!');
    $this->auth->attempt($user->email, $request->getParam('password'));
    return $response->withRedirect($this->router->pathFor('storyupload.guidance'));
  }
public function postCompleteSignUp ( $ request , $ response ) { $ validation = $ this -> validator -> validate ( $ request , [ 'email' => v :: noWhitespace ( ) -> notEmpty ( ) -> email ( ) -> EmailAvailable ( ) , 'password' => v :: noWhitespace ( ) -> notEmpty ( ) , ] ) ; if ( $ validation -> failed ( ) ) { return $ response -> withRedirect ( $ this -> router -> pathFor ( 'auth.completesignup' ) ) ; } $ usermeta = Usermeta :: orderBy ( 'id' , 'desc' ) -> first ( ) ; $ user = User :: create ( [ 'email' => $ request -> getParam ( 'email' ) , 'password' => password_hash ( $ request -> getParam ( 'password' ) , PASSWORD_DEFAULT ) , 'usermeta_id' => $ usermeta -> id , ] ) ; $ this -> flash -> addMessage ( 'success' , 'You have been successfully signed up!' ) ; $ this -> auth -> attempt ( $ user -> email , $ request -> getParam ( 'password' ) ) ; return $ response -> withRedirect ( $ this -> router -> pathFor ( 'storyupload.guidance' ) ) ; }
This method is called when the user submits the final form
This method is called when the user submits the final form
//set up our validation rules for our complete sign up form //if validation fails, stay on complete signup page //$usermeta = Usermeta::find($id)->first(); //We can use our User Model to send the form data to the database //produce a 'toast' when the user signs up successfully //authenticate the user and sign him/her in //after submit, redirect to homepage