Familiar with MVC and terms such as Migrations, Database
Amber Framework CLI already installed (Installation Instructions)
Virtually all web applications require a registering and authenticating users. As a result, most web frameworks have an excessive amount of options for implementing authentication. Amber Framework differs by providing a built-in generator for simple yet secure authentication that is sufficient yet easily extended at a later time. Amber allows you to get started writing your application without getting bogged down in application boilerplate.
First, we generate our app by typing the following command in a terminal console.
amber new blogsy --deps -d sqlite
Commands are performed within the root directory of our project.
Next, we will scaffold our authentication system. The scaffold will generate several files to build a basic authentication system.
amber g auth User
The above command will give you the following output:
08:26:45 Generate | Rendering Auth user08:26:45 Generate | new config/initializers/granite.cr08:26:45 Generate | new spec/models/user_spec.cr08:26:45 Generate | new spec/models/spec_helper.cr08:26:45 Generate | new spec/controllers/spec_helper.cr08:26:45 Generate | new db/migrations/20180110202645523_create_user.sql08:26:45 Generate | new db/seeds.cr08:26:45 Generate | new src/models/user.cr08:26:45 Generate | new src/controllers/registration_controller.cr08:26:45 Generate | new src/controllers/user_controller.cr08:26:45 Generate | new src/controllers/session_controller.cr08:26:45 Generate | new src/views/registration/new.slang08:26:45 Generate | rewritten src/views/layouts/_nav.slang08:26:45 Generate | new src/views/user/show.slang08:26:45 Generate | new src/views/user/edit.slang08:26:45 Generate | new src/views/session/new.slang08:26:45 Generate | new src/handlers/authenticate.cr
To finalize installing the generated authentication system, we have to migrate the database.
amber db create migrate
08:52:25 (INFO) Database | Created database blogsy_development08:52:25 (INFO) Database | Migrating db, current version: 0, target: 2018011020521314708:52:25 (INFO) Database | OK 20180110205213147_create_user.sql
Now we can run our local development server and see our working authentication system.
08:53:52 Watcher | Terminating app Blogsy...08:53:52 Watcher | Compiling Blogsy...08:53:52 Watcher | Building project Blogsy...08:54:05 Server | [Amber 0.6.1] serving application "Blogsy" at http://0.0.0.0:300008:54:05 Server | Server started in development.08:54:05 Server | Startup Time 00:00:00.000596000
To see the signup page visit http://0.0.0.0:3000/signup
Amber framework provides an authentication system generator that allows you to focus on build your application rather than implementation details. The built-in authentication generator is not a full-featured authentication system, it provides the basic framework and can be extended as needed.