Example #1
0
 /**
  * Dashboard /login action
  *
  * @return void
  */
 public function login()
 {
     if (site()->user()) {
         go('dashboard');
     }
     // save the flashed redirect
     flash('login.redirect', flash('login.redirect'));
     if (r::is('post')) {
         if ($this->form->validates()) {
             $user = site()->user($this->form->data('username'));
             if ($user && $user->login($this->form->data('password'))) {
                 flash('messages.success', 'Logged in!');
                 if (get('_redirect')) {
                     go(get('_redirect'));
                 }
             } else {
                 $this->form->addErrors(['login' => 'Invalid username and password']);
             }
         }
         go('login');
     }
     $this->render('dashboard/login', ['pageTitle' => 'Login', 'form' => $this->form, 'page' => page()]);
 }
Example #2
0
<?php

use Crazy\Form;
return function ($site, $pages, $page) {
    $studio = $page->parent();
    $form = new Form(['_token' => ['rules' => ['required', csrf(get('_token'))], 'message' => 'Invalid security token. Please try again.'], 'name' => ['rules' => ['required'], 'message' => 'Name is required'], 'email' => ['rules' => ['required', 'email'], 'message' => 'Valid email is required'], 'phone' => [], 'message' => []]);
    if (r::is('post')) {
        if ($form->validates()) {
            flash('messages.success', "Thanks! We'll be back in touch very soon!");
            event('studio.contacted', array_merge(['studio' => $studio], $form->data()));
        }
        go($page->url());
    }
    return ['studio' => $studio, 'form' => $form];
};