Registracni formular nelze zobrazit ikdyz je v podstate stejny jako Auth

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
michalll
Člen | 7
+
0
-

Ahoj zacinam s nette a vytvoril jsem si prihlasovaci formular ten mi spravne funguje a chci stejnym zpusobem vytvorit jeste registracni a volat ho stejne jako ten prihlasovaci ale nemuze mi ho najit pise mi to :

Nette\InvalidStateException
Resource ‚Admin:Registr‘ does not exist
muj RegistrPresenter

<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */



namespace App\AdminModule\Presenters;
`
use Nette\Application\UI\Form;
 use Nette\Security\AuthenticationException;

/**
 * Description of RegistrPresenter
 *
 * @author michal
 */
class RegistrPresenter extends BasePresenter {

    private $users;
    protected function startup() {
        parent::startup();
        $this->users=  $this->context->user;

    }

    public function renderRegistr(){
    }

    protected function createComponentRegistrForm(){

        $form = new Form;
        $form->addText('name', 'Jméno');
        $form->addText('email', 'E-mail: *', 35)
                ->setEmptyValue('@')
                ->addRule(Form::FILLED, 'Vyplňte Váš email')
                ->addCondition(Form::FILLED)
                ->addRule(Form::EMAIL, 'Neplatná emailová adresa');
        $form->addPassword('password', 'Heslo: *', 20)
                ->setOption('description', 'Alespoň 6 znaků')
                ->addRule(Form::FILLED, 'Vyplňte Vaše heslo')
                ->addRule(Form::MIN_LENGTH, 'Heslo musí mít alespoň %d znaků.', 6);
        $form->addPassword('password2', 'Heslo znovu: *', 20)
                ->addConditionOn($form['password'], Form::VALID)
                ->addRule(Form::FILLED, 'Heslo znovu')
                ->addRule(Form::EQUAL, 'Hesla se neshodují.', $form['password']);
        $form->addSubmit('send', 'Přihlásit');
        $form->onSuccess[] = $this->processRegistrForm;
        return $form;


    }
    public function processRegistrForm(Form $form) {
        try {
        $values = $form->getValues();
        $new_user_id =  $this->users->register($values);
        if($new_user_id){
            $this->flashMessage('Registrace se zdařila, jo!');
        $this->redirect('Sign:in');
        }
        } catch (AuthenticationException $e) {
            $form->addError($e->getMessage());
            $this->flashMessage('Registrace se nedařila, jo!');
        }
    }



}

a zde @layout.latte


<!DOCTYPE html>
<html lang="cs">
    <head>
        <meta charset="utf-8">
        <title>{block title|striptags}Naše první aplikace{/block}</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        {* Styles *}
        <link href="{$basePath}/css/bootstrap.css" rel="stylesheet">

        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
                <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

        {block head}{/block}
    </head>
    <body>
        <div class="navbar navbar-inverse" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand" n:href="Homepage:">Databáze knih</a>
                     </div>
                <div class="navbar-collapse collapse">
                    {if !$user->isLoggedIn()}
                        {form loginForm, class=>'navbar-form navbar-right'}
                            <div class="form-group">{input email, class=>'form-control',placeholder=>'Email'}</div>
                            <div class="form-group">{input password, class=>'form-control',placeholder=>'Heslo'}</div>
                            {input send, class=>'btn btn-success'}
                        {/form}

                    {else}
                        <ul class="nav navbar-nav navbar-right">
                            {if $user->isInRole('admin')}
                                <li><a n:href=":Admin:auth:login">Administracie</a></li>
                                <li><a n:href=" :Admin:registr:registr">Registrovat</a></li>
                                {/if}
                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">{$user->identity->email}<b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    <li><a n:href="logout!">Odhlásit</a></li>
                                </ul>
                            </li>
                        </ul>
                    {/if}
                </div>


            </div>
        </div>
        <div class="container theme-showcase" role="main">
            <div n:foreach="$flashes as $flash" class="alert alert-{$flash->type}">
                <a class="close" data-dismiss="alert">×</a>
                {$flash->message}
            </div>
            {include #content}

        </div>
        <footer>

        </footer>

        <script src="{$basePath}/js/jquery-2.1.0.min.js"></script>
        <script src="{$basePath}/js/bootstrap.min.js"></script>

        <script src="{$basePath}/js/netteForms.js"></script>
        <script src="{$basePath}/js/main.js"></script>
        {block scripts}{/block}
    </body>
</html>

pomohl by mi nekdo prosim co delam spatne? dekuji

romiix.org
Člen | 343
+
0
-

Nemáš zaregistrovaný zdroj.
Pozri https://doc.nette.org/…thentication#….

michalll
Člen | 7
+
0
-

ikdyz ten první formular mam defakto stejny a ten jde bez problemu?

mpis
Člen | 65
+
0
-

No vždyť Ti to píše:
Nette\InvalidStateException
Resource ‘Admin:Registr’ does not exist.
Nemáš asi vytvořený soubor registr.latte, který se pak načítá místo {include #content} v @layout.latte

Editoval mpis (26. 11. 2014 15:44)

David Matějka
Moderator | 6445
+
0
-

Nemas v base presenteru nejaky ACL, ktery detekuje resource dle presenteru?

@mpis to s tim vubec nesouvisi…

Editoval matej21 (26. 11. 2014 15:52)

michalll
Člen | 7
+
0
-

ne e nemam pada mi to zde

  if (!$this->user->isLoggedIn()) {
23:                    if ($this->user->getLogoutReason() === User::INACTIVITY) {
24:                        $this->flashMessage('Session timeout, you have been logged out');
25:                    }
26:
27:                    $this->redirect('Auth:login', array(
28:                        'backlink' => $this->storeRequest()
29:                    ));
30:
31:                } else {
32:  zde|---->         if (!$this->user->isAllowed($this->name, $this->action)) {
33:                        $this->flashMessage('Access denied');
34:                        $this->redirect('Default:');
35:                    }
36:                }
David Matějka
Moderator | 6445
+
0
-

no to je ono.. overujes tam dle aktualniho presenteru, ale neexistuje resource

michalll
Člen | 7
+
0
-

muzes me prosimte navezt teprve asi mesic se to ucim tak nejakym spravnym smerem? dekuji :)

Jan Suchánek
Člen | 404
+
0
-

Mrkni sem. Nemáš v Permision zaregistrovaný


$acl->allow('guest', 'Admin:Register');

Editoval jenicek (26. 11. 2014 17:53)

michalll
Člen | 7
+
0
-

Dekuji mrknu na to :)