Module: Ramaze::Helper::Admin

### Home Classes Methods

### In Files

- lib/thoth/helper/admin.rb

### Methods

- ::included
- #login
- #logout

### Files

- robots.txt

### Class/Module Index

Quicksearch

- Thoth
- Thoth::AdminController
- Thoth::ArchiveController
- Thoth::Comment
- Thoth::CommentApiController
- Thoth::CommentController
- Thoth::Config
- Thoth::Error
- Thoth::Importer
- Thoth::MainController
- Thoth::Media
- Thoth::MediaController
- Thoth::MinifyController
- Thoth::Page
- Thoth::PageApiController
- Thoth::PageController
- Thoth::Pager
- Thoth::Plugin
- Thoth::Plugin::Delicious
- Thoth::Plugin::Flickr
- Thoth::Plugin::Tags
- Thoth::Plugin::Twitter
- Thoth::Post
- Thoth::PostApiController
- Thoth::PostController
- Thoth::SchemaError
- Thoth::SearchController
- Thoth::Tag
- Thoth::TagApiController
- Thoth::TagController
- Thoth::TagsPostsMap
- Ramaze
- Ramaze::Dispatcher
- Ramaze::Dispatcher::File
- Ramaze::Helper
- Ramaze::Helper::Admin
- Ramaze::Helper::Cookie
- Ramaze::Helper::Error
- Ramaze::Helper::Pagination
- Ramaze::Helper::Sanitize
- Ramaze::Helper::Wiki
- Ramaze::Helper::Ysearch
- Ramaze::Helper::Ysearch::SearchError
- AddMediaSize
- CreateSchema
- PantsImporter
- PoseidonImporter

No matching classes.

# Ramaze::Helper::Admin

The Admin helper provides genric `login` and `logout` actions for handling Thoth administrator logins and logouts, along with methods for checking for or requiring authorization from within other actions and views.

### Public Class Methods

included(klass) click to toggle source

Include cookie helper.

    # File lib/thoth/helper/admin.rb, line 38
    def self.included(klass)
      klass.send(:helper, :cookie)
    end

### Public Instance Methods

login() click to toggle source

Authenticates an admin login by checking the `username` and `password` request parameters against the ADMIN_USER and ADMIN_PASS values in the Thoth config file.

On a successful login, an auth cookie named `thoth_auth` will be set and the user will be redirected to the referring URL. On an unsuccessful login attempt, a flash message named `login_error` will be set and the user will be redirected to the referring URL without an auth cookie.

    # File lib/thoth/helper/admin.rb, line 50
    def login
      username, password = request[:username, :password]

      if username == Thoth::Config.admin.user &&
          password == Thoth::Config.admin.pass
        # Set an auth cookie that expires in two weeks.
        response.set_cookie('thoth_auth', :expires => Time.now + 1209600,
            :path => R(Thoth::MainController), :value => auth_key)

        redirect_referrer
      end

      flash[:error] = 'Invalid username or password.'
      redirect_referrer
    end

logout() click to toggle source

Deletes the `thoth_auth` cookie and redirects to the home page.

    # File lib/thoth/helper/admin.rb, line 67
    def logout
      response.delete_cookie('thoth_auth', :path => R(Thoth::MainController))
      redirect(R(Thoth::MainController))
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.