Admin Usage

Follow the instructions in your terminal and provide a valid email and
password for your newly created admin account:

edit your config/database.rb

create the database: $ bundle exec rake db:create

migrate your database: $ bundle exec rake db:migrate

seed your database with some data: $ bundle exec rake db:seed

Your admin section is now "setup": you can start padrino padrino s and
point your web browser to http://localhost:3000/admin and log in with your
admin account credentials.

If you need to create a "scaffold", (basic CRUD actions) create a
model, migrate your database, generate your scaffolding folder structure and
views and add those to your admin section by running the following commands:

Admin Authentication

Scenario E-commerce (User Authentication)

To use a practical example, let's examine a common e-commerce application
scenario, where we need to limit access to some of our controllers actions;
we can easily accomplish this by editing app.rb accordingly:

In the above example we protect paths starting with /customer/orders
and /cart/checkout. The result will be that an unauthenticated user will
not be able to access those actions, and they will be asked to authenticate;
first by visiting our :login_page defined as /login and by providing their
login credentials (default authentication behaviour will use email and password).

When successfully logged in, they will be granted access to the two protected pages.

Admin Scenario (User Authorization)

Another common scenario is needing multiple roles with various level of access,
instead of providing all management functionality to all logged in users.

Consider a site where you want to allow unauthenticated users to login, an
editor to manage posts and categories, and an admin role to manage settings.

The Padrino admin generator will by default create an Account model with a
role attribute which you can combine with the project_module method to
easily manage which functionality is available to your users.

In the above example, we protect the entire admin section (all paths starting
with "/") with the only exception for all those paths starting with /sessions
giving our unauthenticated users the possibility to log in by redirecting them
to our login page and asking them to provide their email and password.

If we are logged in as an admin (account.role == 'admin') we will only
have access to the /settings path.

If we are logged in as an editor (account.role == 'editor') we will only
have access to the /posts and /categories paths.

Sharing Sessions Between Mounted Applications

Sessions can be shared between mounted applications by setting a :session_id
with the line set :session_id, "your_session_id" in each apps app.rb.

Contributing Persistence Adapters

If you are planning to use padrino with other adapters rather than the currently
supported ones, and you want to contribute to the project by extending its
support with additional adapters like ohm, ruby-driver and
so on, be sure to check out the
adding components
guide.