Login Engineの動きを確認する。

Login Engineをインストールしたが、どんな機能があるのか分からないので、ひたすら画面を操作して試行錯誤してみる。

初めてのログイン!

インストール後、初めて下記URLを開こうとすると、

http://0.0.0.0:3000/softwares

次のURLへ、リダイレクトされ、

http://0.0.0.0:3000/user/login

ログインを要求される。

まだユーザー登録していないので、Register for an accountをクリックして、


ユーザー登録ページへ移動する。

必要事項を入力して、Signupボタンを押すと、


再びログインページになる。

そこにはメッセージが表示されている。
「Signup successful! Please check your registered email account to verify your account registration and continue with the login.」
意味としては以下のような内容だと思われる。
「申し込みを受け付けました。登録したメールをチェックして、ユーザー登録の確認手続きをしてから、ログインを続けてください。」


メールをチェックすると、以下の内容で届いている。

   From: MY_USER_NAME@mac.com
Subject: [TestApp] Welcome to TestApp!
   Date: 2006年12月4日 12:00:00:JST
     To: taro@gmail.com

Welcome to TestApp, 太郎 山田.

Your login credentials are:

  login:    yamada
  password: dokabenn

Please click on the following link to confirm your registration:

<a href="http://0.0.0.0:3007/user/home?key=658443f4e6822a864722ebf43897d5b41aa7cf86&user_id=3">Click me!</a>

http://0.0.0.0:3007/user/home?key=658443f4e6822a864722ebf43897d5b41aa7cf86&user_id=3


リンクをクリックすると、ユーザー登録の確認手続きが完了し、ログイン状態となる。(メールに書かれたリンクをクリックするまでは、ログインページからもログインすることは出来ない。)

この状態で、下記アドレスへ再度アクセスすれば、一覧表示のページが表示される。

http://0.0.0.0:3000/softwares


ログインの確認のため、一度webブラウザを終了する。*1
再度、webブラウザを起動して、下記アドレスを入力してみる。

http://0.0.0.0:3000/softwares

ログインを要求されるので、IDとパスワードを入力してログインしてみる。


ログインが完了して、一覧表示のページが表示された!

アクションメソッド

vender/plugins/login_engine/app/controllers/user_controller.rbで、どんなアクションメソッドがあるか、確認してみた。

home
調査中
login
before_filterで、ログインが必要な時に呼び出される。
signup
ユーザー登録ページのSignupボタンで呼び出される。
logout
ログアウトする。開発しているアプリケーションのページ内に、自分でリンクを設定してあげる必要あり。
change_password
パスワードの変更をする。変更後、メールで通知される。開発しているアプリケーションのページ内に、自分でリンクを設定してあげる必要あり。
forgot_password
ログインページに、リンクあり。自分の登録したメールアドレスを入力すると、メールが送信される。そのメールのリンクをクリックすると、パスワードの再設定が出来る。
edit
調査中
delete
調査中
restore_deleted
調査中

デフォルト設定の確認

vender/plugins/login_engine/lib/login-engine.rb
デフォルトを変更したい箇所だけコピーして、config/environment.rbで自分流に追記すればOK。

require 'login_engine/authenticated_user'
require 'login_engine/authenticated_system'

module LoginEngine
 include AuthenticatedSystem # re-include the helper module

  #--
  # Define the configuration values. config sets the value of the
  # constant ONLY if it has not already been set, i.e. by the user in
  # environment.rb
  #++

  # Source address for user emails(Login Engineの送信元メールアドレス)
  config :email_from, 'webmaster@your.company'

  # Destination email for system errors(調査中)
  config :admin_email, 'webmaster@your.company'

  # Sent in emails to users(送信するメールの本文に記入される)
  config :app_url, 'http://localhost:3000/'

  # Sent in emails to users(送信するメールのタイトルに記入される)
  config :app_name, 'TestApp'

  # Email charset(調査中、送信するメールのエンコード?)
  config :mail_charset, 'utf-8'

  # Security token lifetime in hours(調査中、おそらくメールに書かれ確認手続きの有効期限は24時間?)
  config :security_token_life_hours, 24

  # Two column form input((調査中)
  config :two_column_input, true

  # Add all changeable user fields to this array.
  # They will then be able to be edited from the edit action. You
  # should NOT include the email field in this array.(調査中)
  config :changeable_fields, [ 'firstname', 'lastname' ]

  # Set to true to allow delayed deletes (i.e., delete of record
  # doesn't happen immediately after user selects delete account,
  # but rather after some expiration of time to allow this action
  # to be reverted).(調査中、おそらくユーザーを削除したとき、一定の猶予期間は復元を可能にする機能を有効にするかどうか。デフォルトは復元不可能。)
  config :delayed_delete, false

  # Default is one week(調査中、おそらく上記の猶予期間の設定)
  config :delayed_delete_days, 7
  
  # the table to store user information in(ログイン管理する時のテーブル名、デフォルトはusers。)
  if ActiveRecord::Base.pluralize_table_names
    config :user_table, "users"
  else
    config :user_table, "user"
  end

  # controls whether or not email is used(メールを利用して管理するかどうか、デフォルトはメールを利用する。)
  config :use_email_notification, true

  # Controls whether accounts must be confirmed after signing up
  # ONLY if this and use_email_notification are both true(新規のユーザー登録で、メールでの確認手続きをするかどうか。デフォルトはメール確認する。)
  config :confirm_account, true

end

*1:デフォルト設定では、ログインの有効期限はログアウトするか、webブラウザを終了するまで維持されるらしい。まだログアウトの機能をつけていないので、一旦終了してみた。