# Log in with virtual page

**URL:** <https://forum.getkirby.com/t/log-in-with-virtual-page/16868>\
**Category:** Questions\
**Tags:** v3\
**Created:** [January 14, 2020, 9:10pm UTC](https://forum.getkirby.com/t/log-in-with-virtual-page/16868 "2020-01-14T21:10:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Turqueso](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/turqueso/32/8058_2.png) [@Turqueso](https://forum.getkirby.com/u/Turqueso)\
**Post date:** [January 14, 2020, 9:10pm UTC](https://forum.getkirby.com/t/log-in-with-virtual-page/16868/1 "2020-01-14T21:10:16Z")

</div>

I’m following the [Restricting access coockbook](https://getkirby.com/docs/cookbook/security/access-restriction) but I would like the page to be a virtual one. I converted the `.txt` files (It’s multi-language site) to a virtual page following the example of [simple virtual page guide for multilingual site](https://getkirby.com/docs/guide/virtual-pages/simple-virtual-page) and deleted the page from the content folder

The page shows up but when I login it sends me to the error page. I did not modified any other files.

It works if I comment out the routes and use the txt files on the content folder. Here are the txt files and the virtual page:

login.es.txt

```
Title: Iniciar sesión

----

Alert: Correo o contraseña inválidos.

----

Email: Correo electrónico

----

Password: Contraseña

----

Button: Iniciar sesión

```

login.en.txt

```
Title: Login

----

Alert: Invalid user or password

----

Email: Email

----

Password: Password

----

Button: Log in

```

my config.php

```
<?php

return [
    'debug' => true,
    'languages' => true,
    'date.handler' => 'strftime',
    'languages.detect' => true,
    'routes' => [
        [
            'pattern' => '(es|en)/login',
            'action' => function ($lang) {

                $data = [
                    'slug' => 'login',
                    'template' => 'login',
                    'translations' => [
                        'es' => [
                            'code' => 'es',
                            'content' => [
                                'title' => 'Iniciar sesión',
                                'alert' => 'Correo o contraseña no válidos.',
                                'email' => 'Correo electrónico',
                                'password' => 'Contraseña',
                                'button' => 'Iniciar sesion'
                            ]
                        ],
                        'en' => [
                            'code' => 'en',
                            'content' => [
                                'title' => 'Login',
                                'alert' => 'Invalid user or password.',
                                'email' => 'Email',
                                'password' => 'Password',
                                'button' => 'Log in'
                            ]
                        ]
                    ],
                ];

                $page = Page::factory($data);

                site()->visit($page, $lang);

                return $page;
            }
        ],
        [
            'pattern' => '(es|en)/logout',
            'action' => function() {

            if ($user = kirby()->user()) {
                $user->logout();
            }

            go(kirby()->languageCode() . '/login');

            }
        ]
    ]
];

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [January 14, 2020, 9:21pm UTC](https://forum.getkirby.com/t/log-in-with-virtual-page/16868/2 "2020-01-14T21:21:50Z")

</div>

What’s the point of doing it like this?

---

<div class="post-metadata">

**Author:** ![Turqueso](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/turqueso/32/8058_2.png) [@Turqueso](https://forum.getkirby.com/u/Turqueso)\
**Post date:** [January 14, 2020, 9:24pm UTC](https://forum.getkirby.com/t/log-in-with-virtual-page/16868/3 "2020-01-14T21:24:04Z")

</div>

So the page won’t show up on the list of pages and test what can be done with kirby 😛 If it’s not possible it’s ok!

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [January 14, 2020, 9:34pm UTC](https://forum.getkirby.com/t/log-in-with-virtual-page/16868/4 "2020-01-14T21:34:21Z")

</div>

But the reason why this is happening is not that it doesn’t work, but that your route only listens to a `GET` request. Add

```auto
'method' => 'GET|POST',

```

to your route and you should be good to go.

---

<div class="post-metadata">

**Author:** ![Turqueso](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/turqueso/32/8058_2.png) [@Turqueso](https://forum.getkirby.com/u/Turqueso)\
**Post date:** [January 14, 2020, 9:40pm UTC](https://forum.getkirby.com/t/log-in-with-virtual-page/16868/5 "2020-01-14T21:40:03Z")

</div>

It works, thanks!
