Example of user management in Nette

Overview

User Authentication (Nette example)

Example of user management.

  • User login, registration and logout (SignPresenter)
  • Command line registration (bin/create-user.php)
  • Authentication using database table (UserFacade)
  • Password hashing
  • Presenter requiring authentication (DashboardPresenter) using the RequireLoggedUser trait
  • Rendering forms using Bootstrap CSS framework
  • Automatic CSRF protection using a token when the user is logged in (FormFactory)
  • Separation of form factories into independent classes (SignInFormFactory, SignUpFormFactory)
  • Return to previous page after login (SignPresenter::$backlink)

Installation

git clone https://github.com/nette-examples/user-authentication
cd user-authentication
composer update

Set the database access data in the config/local.neon file:

database:
	dsn: 'mysql:host=127.0.0.1;dbname=***'
	user: ***
	password: ***

And create a users table in the database by importing the users.mysql.sql file

The simplest way to get started is to start the built-in PHP server in the root directory of your project:

php -S localhost:8000 -t www

Then visit http://localhost:8000 in your browser to see the welcome page.

You might also like...
Kaiju is an open source verification bot based on Discord's OAuth written in C# and PHP, with the functionality of being able to integrate the user to a new server in case yours is suspended.
Kaiju is an open source verification bot based on Discord's OAuth written in C# and PHP, with the functionality of being able to integrate the user to a new server in case yours is suspended.

What is Kaiju? Kaiju is an open source verification bot for Discord servers, based on OAuth and with permission for the server owner, to be able to mi

Easy, native Laravel user authorization.

An easy, native role / permission management system for Laravel. Index Installation Migration Customization Model Customization Usage Checking Permiss

User Authentication Managment With Laravel 8

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

User registration and login form with validations and escapes for total security made with PHP.

Login and Sign Up with PHP User registration and login form with validations and escapes for total security made with PHP. Validations Required fields

Helps you securely setup a master password and login into user accounts with it.
Helps you securely setup a master password and login into user accounts with it.

🔑 Make your Login form smart in a minute! Built with ❤️ for every smart laravel developer Helps you set a master password in .env file and login into

this is a semester project using Laravel, this app allow user to keep and shear their note with other users.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Redirects any user which hasn't setup two factor authentication yet to /2fa/

force-two-factor Redirects any user which hasn't setup two factor authentication yet to /2fa/. Use together with the forked two-factor plugin at https

Log user authentication details and send new device notifications.
Log user authentication details and send new device notifications.

Laravel Authentication Log is a package which tracks your user's authentication information such as login/logout time, IP, Browser, Location, etc. as well as sends out notifications via mail, slack, or sms for new devices and failed logins.

Auth is a module for the Yii PHP framework that provides a web user interface for Yii's built-in authorization manager

Auth is a module for the Yii PHP framework that provides a web user interface for Yii's built-in authorization manager (CAuthManager). You can read more about Yii's authorization manager in the framework documentation under Authentication and Authorization.

Comments
  • Following readme instructions results in Exception.

    Following readme instructions results in Exception.

    Following the instructions from readme file and testing the application with php -S localhost:8000 www/index.php will make the browser redirect to http://localhost:8000/admin.sign/in and result in the following exception:

    Nette\Application\BadRequestException #404
    Cannot load presenter 'In', class 'App\Module\Presenters\InPresenter' was not found.
    
    Caused by:
    Nette\Application\InvalidPresenterException
    Cannot load presenter 'In', class 'App\Module\Presenters\InPresenter' was not found.
    

    PHP version used is 7.4.26.

    opened by marekrost 7
  • Invalid URL routing: Cannot load presenter 'In'

    Invalid URL routing: Cannot load presenter 'In'

    Related to #3 #4

    Running application via PHP built-in webserver results in Cannot load presenter 'In', class 'App\Module\Presenters\InPresenter' was not found. exception.

    PHP built-in vs. Apache requests differ:

    Apache
    ======
    URL: https://test.l/admin.sign/in?backlink=ugf6h
    UrlScript::$scriptPath: /
    UrlScript::$basePath:   /
    
    PHP built-in
    ============
    URL: http://localhost:8000/admin.sign/in?backlink=8j97c
    UrlScript::$scriptPath: /admin.sign/in
    UrlScript::$basePath:   /admin.sign/
    

    That's because of RequestFactory::getScriptPath() detects it from $_SERVER['SCRIPT_NAME']:

    Apache
    ======
    $path:                 /admin.sign/in
    $_SERVER[SCRIPT_NAME]: /index.php
    
    PHP built-in
    ============
    $path:                 /admin.sign/in
    $_SERVER[SCRIPT_NAME]: /admin.sign/in
    
    

    I don't know how to fix it. Moreover, no one wants to touch this part :) Maybe workaround it:

    private function getScriptPath(Url $url): string
    {
       if (PHP_SAPI === 'cli-server') {
            return '/';
       }
       ...
    }
    

    Whole dump of $_SERVER for PHP built-in webserver:

    Array
    (
        [DOCUMENT_ROOT] => D:\Web\temp\user-authentication
        [REMOTE_ADDR] => ::1
        [REMOTE_PORT] => 59094
        [SERVER_SOFTWARE] => PHP 8.1.0 Development Server
        [SERVER_PROTOCOL] => HTTP/1.1
        [SERVER_NAME] => localhost
        [SERVER_PORT] => 8000
        [REQUEST_URI] => /admin.sign/in?backlink=8j97c
        [REQUEST_METHOD] => GET
        [SCRIPT_NAME] => /admin.sign/in
        [SCRIPT_FILENAME] => www/index.php
        [PHP_SELF] => /admin.sign/in
        [QUERY_STRING] => backlink=8j97c
        [HTTP_HOST] => localhost:8000
        [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0
        [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
        [HTTP_ACCEPT_LANGUAGE] => cs,sk;q=0.8,en-US;q=0.5,en;q=0.3
        [HTTP_ACCEPT_ENCODING] => gzip, deflate
        [HTTP_CONNECTION] => keep-alive
        [HTTP_COOKIE] => tracy-session=c919389757; _nss=1; PHPSESSID=qijk27euoucmanqqpg5o20uham
        [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
        [HTTP_SEC_FETCH_DEST] => document
        [HTTP_SEC_FETCH_MODE] => navigate
        [HTTP_SEC_FETCH_SITE] => none
        [HTTP_SEC_FETCH_USER] => ?1
        [HTTP_CACHE_CONTROL] => max-age=0
        [REQUEST_TIME_FLOAT] => 1648813226.3869
        [REQUEST_TIME] => 1648813226
    )
    
    opened by milo 2
  • Cannot use the included sqlite database with create-user.php script.

    Cannot use the included sqlite database with create-user.php script.

    The table users included within the file users.sqlite.db contains NOT NULL constraint on the role column.

    Attempting to use bin/create-user.php with this database will result in the following error:

    ERROR: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: users.role
    Check log to see more info.
    
    opened by marekrost 1
  • Unable to pass parameters to action

    Unable to pass parameters to action

    Thanks for another nice example project of Nettes great capabilities.

    I followed the instructions in the readme, but get this error, when running on my machine.

    image

    I use Windows 10/firefox/php 8.07.

    opened by eydun 1
Owner
null
Armor - User and Session Management

User and session management. Provides solid base foundation for development of custom user management system.

Matt Dizak 3 Apr 13, 2022
UserFrosting is a secure, modern user management system written in PHP and built on top of the Slim Microframework, Twig templating engine, and Eloquent ORM.

UserFrosting is a secure, modern user management system written in PHP and built on top of the Slim Microframework, Twig templating engine, and Eloquent ORM.

UserFrosting 1.6k Jan 1, 2023
User role and Permission Management system with Paticie package

User role and Permission Management system with Paticie package Installation instruction Download or git clone https://github.com/KKOO727/User-role-ma

Ninja 2 Mar 4, 2022
A user, group, role and permission management for Codeigniter 4

CI4-Auth CI4-Auth is a user, group, role and permission management library for Codeigniter 4. CI4-Auth is based on the great Myth-Auth library for Cod

George Lewe 15 Dec 16, 2022
Tech-Admin is Laravel + Bootstrap Admin Panel With User Management And Access Control based on Roles and Permissions.

Tech-Admin | Laravel 8 + Bootstrap 4 Tech-Admin is Admin Panel With Preset of Roles, Permissions, ACL, User Management, Profile Management. Features M

TechTool India 39 Dec 23, 2022
example of LexikJWTAuthenticationBundle with Symfony 4.4

Install Dependency composer install Generate the SSL keys: php bin/console lexik:jwt:generate-keypair Create database php bin/console doctrine:datab

Yunus Emre Bulut 1 Nov 10, 2021
PHP library to verify and validate Apple IdentityToken and authenticate a user with Apple ID.

Sign-in with Apple SDK Installation Recommended and easiest way to installing library is through Composer. composer require azimolabs/apple-sign-in-ph

Azimo Labs 79 Nov 8, 2022
PHP package built for Laravel 5.* to easily handle a user email verification and validate the email

jrean/laravel-user-verification is a PHP package built for Laravel 5.* & 6.* & 7.* & 8.* to easily handle a user verification and validate the e-mail.

Jean Ragouin 802 Dec 29, 2022
Quickly create `User` models with Artisan. ⚡️

Quickly create User models with Artisan. Installation You can install the package via composer: composer require ryangjchandler/laravel-make-user Usag

Ryan Chandler 14 Oct 7, 2022
Instantly login as user via a single button tap on dev environments.

Getting tired of always entering login details in local dev environments? This package adds a button to instantly login a user! Installation You can i

Quinten Buis 3 Feb 18, 2022