codeforamerica/cityvoice — pull request #130 by invisiblefunnel (2013-11-12 21:20:03+00:00)
Title: Admin model with Devise authentication

These changes setup the application to allow app-wide settings (and other privileged resources) to be managed through the web ui by admin users.

I've used the Devise registerable module to allow admins to change their email and password, but deny access to the new and create actions so admin records must be created via console or seeds. Admins can visit `/admins/sign_in` to login. Navigation links to edit an account and sign out are shown in the navbar if `admin_signed_in?`. Require admin privileges for a controller or action with `before_action :authenticate_admin!`.

A note: recent Devise versions require a secret key to be set which is used to generate random tokens. I don't think this key should be committed to the repository so it needs to be set through the `DEVISE_SECRET_KEY` environment variable except in development and test environments. See [related discussion](https://github.com/plataformatec/devise/issues/2554#issuecomment-24108495).

Feedback appreciated!