There's now 3 account activation strategies (available in application settings):
* activation by email: the user receives an email containing a link to active his account * manual activation: an email is sent to administrators for account approval (default) * automatic activation: the user can log in as soon as he has registered git-svn-id: http://redmine.rubyforge.org/svn/trunk@915 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f8aa2dc9b7
commit
9c9ae21771
|
@ -21,7 +21,7 @@ class AccountController < ApplicationController
|
|||
include CustomFieldsHelper
|
||||
|
||||
# prevents login action to be filtered by check_if_login_required application scope filter
|
||||
skip_before_filter :check_if_login_required, :only => [:login, :lost_password, :register]
|
||||
skip_before_filter :check_if_login_required, :only => [:login, :lost_password, :register, :activate]
|
||||
|
||||
# Show user's account
|
||||
def show
|
||||
|
@ -106,40 +106,62 @@ class AccountController < ApplicationController
|
|||
# User self-registration
|
||||
def register
|
||||
redirect_to(home_url) && return unless Setting.self_registration?
|
||||
if params[:token]
|
||||
token = Token.find_by_action_and_value("register", params[:token])
|
||||
redirect_to(home_url) && return unless token and !token.expired?
|
||||
user = token.user
|
||||
redirect_to(home_url) && return unless user.status == User::STATUS_REGISTERED
|
||||
user.status = User::STATUS_ACTIVE
|
||||
if user.save
|
||||
token.destroy
|
||||
flash[:notice] = l(:notice_account_activated)
|
||||
redirect_to :action => 'login'
|
||||
return
|
||||
end
|
||||
if request.get?
|
||||
@user = User.new(:language => Setting.default_language)
|
||||
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
|
||||
else
|
||||
if request.get?
|
||||
@user = User.new(:language => Setting.default_language)
|
||||
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user) }
|
||||
else
|
||||
@user = User.new(params[:user])
|
||||
@user.admin = false
|
||||
@user.login = params[:user][:login]
|
||||
@user.status = User::STATUS_REGISTERED
|
||||
@user.password, @user.password_confirmation = params[:password], params[:password_confirmation]
|
||||
@user = User.new(params[:user])
|
||||
@user.admin = false
|
||||
@user.login = params[:user][:login]
|
||||
@user.status = User::STATUS_REGISTERED
|
||||
@user.password, @user.password_confirmation = params[:password], params[:password_confirmation]
|
||||
if params["custom_fields"]
|
||||
@custom_values = UserCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @user, :value => params["custom_fields"][x.id.to_s]) }
|
||||
@user.custom_values = @custom_values
|
||||
end
|
||||
case Setting.self_registration
|
||||
when '1'
|
||||
# Email activation
|
||||
token = Token.new(:user => @user, :action => "register")
|
||||
if @user.save and token.save
|
||||
Mailer.deliver_register(token)
|
||||
flash[:notice] = l(:notice_account_register_done)
|
||||
redirect_to :controller => 'account', :action => 'login'
|
||||
redirect_to :action => 'login'
|
||||
end
|
||||
when '3'
|
||||
# Automatic activation
|
||||
@user.status = User::STATUS_ACTIVE
|
||||
if @user.save
|
||||
flash[:notice] = l(:notice_account_activated)
|
||||
redirect_to :action => 'login'
|
||||
end
|
||||
else
|
||||
# Manual activation by the administrator
|
||||
if @user.save
|
||||
# Sends an email to the administrators
|
||||
Mailer.deliver_account_activation_request(@user)
|
||||
flash[:notice] = l(:notice_account_pending)
|
||||
redirect_to :action => 'login'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Token based account activation
|
||||
def activate
|
||||
redirect_to(home_url) && return unless Setting.self_registration? && params[:token]
|
||||
token = Token.find_by_action_and_value('register', params[:token])
|
||||
redirect_to(home_url) && return unless token and !token.expired?
|
||||
user = token.user
|
||||
redirect_to(home_url) && return unless user.status == User::STATUS_REGISTERED
|
||||
user.status = User::STATUS_ACTIVE
|
||||
if user.save
|
||||
token.destroy
|
||||
flash[:notice] = l(:notice_account_activated)
|
||||
end
|
||||
redirect_to :action => 'login'
|
||||
end
|
||||
|
||||
private
|
||||
def logged_user=(user)
|
||||
if user && user.is_a?(User)
|
||||
|
|
|
@ -88,6 +88,14 @@ class Mailer < ActionMailer::Base
|
|||
:password => password,
|
||||
:login_url => url_for(:controller => 'account', :action => 'login')
|
||||
end
|
||||
|
||||
def account_activation_request(user)
|
||||
# Send the email to all active administrators
|
||||
recipients User.find_active(:all, :conditions => {:admin => true}).collect { |u| u.mail }.compact
|
||||
subject l(:mail_subject_account_activation_request)
|
||||
body :user => user,
|
||||
:url => url_for(:controller => 'users', :action => 'index', :status => User::STATUS_REGISTERED, :sort_key => 'created_on', :sort_order => 'desc')
|
||||
end
|
||||
|
||||
def lost_password(token)
|
||||
set_language_if_valid(token.user.language)
|
||||
|
@ -102,7 +110,7 @@ class Mailer < ActionMailer::Base
|
|||
recipients token.user.mail
|
||||
subject l(:mail_subject_register)
|
||||
body :token => token,
|
||||
:url => url_for(:controller => 'account', :action => 'register', :token => token.value)
|
||||
:url => url_for(:controller => 'account', :action => 'activate', :token => token.value)
|
||||
end
|
||||
|
||||
def test(user)
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
<% for @custom_value in @custom_values %>
|
||||
<p><%= custom_field_tag_with_label @custom_value %></p>
|
||||
<% end %>
|
||||
|
||||
<p><label for="user_mail_notification"><%=l(:field_mail_notification)%></label>
|
||||
<%= check_box 'user', 'mail_notification' %></p>
|
||||
<!--[eoform:user]-->
|
||||
</div>
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<p><%= l(:mail_body_account_activation_request, @user.login) %></p>
|
||||
<p><%= link_to @url, @url %></p>
|
|
@ -0,0 +1,2 @@
|
|||
<%= l(:mail_body_account_activation_request, @user.login) %>
|
||||
<%= @url %>
|
|
@ -78,7 +78,12 @@
|
|||
<%= select_tag 'settings[autologin]', options_for_select( [[l(:label_disabled), "0"]] + [1, 7, 30, 365].collect{|days| [lwr(:actionview_datehelper_time_in_words_day, days), days.to_s]}, Setting.autologin) %></p>
|
||||
|
||||
<p><label><%= l(:setting_self_registration) %></label>
|
||||
<%= check_box_tag 'settings[self_registration]', 1, Setting.self_registration? %><%= hidden_field_tag 'settings[self_registration]', 0 %></p>
|
||||
<%= select_tag 'settings[self_registration]',
|
||||
options_for_select( [[l(:label_disabled), "0"],
|
||||
[l(:label_registration_activation_by_email), "1"],
|
||||
[l(:label_registration_manual_activation), "2"],
|
||||
[l(:label_registration_automatic_activation), "3"]
|
||||
], Setting.self_registration ) %></p>
|
||||
|
||||
<p><label><%= l(:label_password_lost) %></label>
|
||||
<%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p>
|
||||
|
|
|
@ -28,7 +28,7 @@ welcome_text:
|
|||
login_required:
|
||||
default: 0
|
||||
self_registration:
|
||||
default: 1
|
||||
default: '2'
|
||||
lost_password:
|
||||
default: 1
|
||||
attachment_max_size:
|
||||
|
|
|
@ -538,3 +538,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -538,3 +538,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -538,3 +538,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
10
lang/en.yml
10
lang/en.yml
|
@ -75,6 +75,7 @@ notice_email_error: An error occurred while sending mail (%s)
|
|||
notice_feeds_access_key_reseted: Your RSS access key was reseted.
|
||||
notice_failed_to_save_issues: "Failed to save %d issue(s) on %d selected: %s."
|
||||
notice_no_issue_selected: "No issue is selected! Please, check the issues you want to edit."
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
||||
mail_subject_lost_password: Your Redmine password
|
||||
mail_body_lost_password: 'To change your Redmine password, click on the following link:'
|
||||
|
@ -82,6 +83,8 @@ mail_subject_register: Redmine account activation
|
|||
mail_body_register: 'To activate your Redmine account, click on the following link:'
|
||||
mail_body_account_information_external: You can use your "%s" account to log into Redmine.
|
||||
mail_body_account_information: Your Redmine account information
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
|
||||
gui_validation_error: 1 error
|
||||
gui_validation_error_plural: %d errors
|
||||
|
@ -171,8 +174,8 @@ setting_app_title: Application title
|
|||
setting_app_subtitle: Application subtitle
|
||||
setting_welcome_text: Welcome text
|
||||
setting_default_language: Default language
|
||||
setting_login_required: Authent. required
|
||||
setting_self_registration: Self-registration enabled
|
||||
setting_login_required: Authentication required
|
||||
setting_self_registration: Self-registration
|
||||
setting_attachment_max_size: Attachment max. size
|
||||
setting_issues_export_limit: Issues export limit
|
||||
setting_mail_from: Emission email address
|
||||
|
@ -446,6 +449,9 @@ label_user_mail_option_all: "For any event on all my projects"
|
|||
label_user_mail_option_selected: "For any event on the selected projects only..."
|
||||
label_user_mail_option_none: "Only for things I watch or I'm involved in"
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
label_registration_activation_by_email: account activation by email
|
||||
label_registration_manual_activation: manual account activation
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
|
||||
button_login: Login
|
||||
button_submit: Submit
|
||||
|
|
|
@ -541,3 +541,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
10
lang/fr.yml
10
lang/fr.yml
|
@ -75,6 +75,7 @@ notice_email_error: "Erreur lors de l'envoi de l'email (%s)"
|
|||
notice_feeds_access_key_reseted: Votre clé d'accès aux flux RSS a été réinitialisée.
|
||||
notice_failed_to_save_issues: "%d demande(s) sur les %d sélectionnées n'ont pas pu être mise(s) à jour: %s."
|
||||
notice_no_issue_selected: "Aucune demande sélectionnée ! Cochez les demandes que vous voulez mettre à jour."
|
||||
notice_account_pending: "Votre compte a été créé et attend l'approbation de l'administrateur."
|
||||
|
||||
mail_subject_lost_password: Votre mot de passe redMine
|
||||
mail_body_lost_password: 'Pour changer votre mot de passe Redmine, cliquez sur le lien suivant:'
|
||||
|
@ -82,6 +83,8 @@ mail_subject_register: Activation de votre compte redMine
|
|||
mail_body_register: 'Pour activer votre compte Redmine, cliquez sur le lien suivant:'
|
||||
mail_body_account_information_external: Vous pouvez utiliser votre compte "%s" pour vous connecter à Redmine.
|
||||
mail_body_account_information: Paramètres de connexion de votre compte Redmine
|
||||
mail_subject_account_activation_request: "Demande d'activation d'un compte Redmine"
|
||||
mail_body_account_activation_request: "Un nouvel utilisateur (%s) s'est inscrit. Son compte nécessite votre approbation:"
|
||||
|
||||
gui_validation_error: 1 erreur
|
||||
gui_validation_error_plural: %d erreurs
|
||||
|
@ -171,8 +174,8 @@ setting_app_title: Titre de l'application
|
|||
setting_app_subtitle: Sous-titre de l'application
|
||||
setting_welcome_text: Texte d'accueil
|
||||
setting_default_language: Langue par défaut
|
||||
setting_login_required: Authentif. obligatoire
|
||||
setting_self_registration: Enregistrement autorisé
|
||||
setting_login_required: Authentification obligatoire
|
||||
setting_self_registration: Inscription des nouveaux utilisateurs
|
||||
setting_attachment_max_size: Taille max des fichiers
|
||||
setting_issues_export_limit: Limite export demandes
|
||||
setting_mail_from: Adresse d'émission
|
||||
|
@ -446,6 +449,9 @@ label_user_mail_option_all: "Pour tous les événements de tous mes projets"
|
|||
label_user_mail_option_selected: "Pour tous les événements des projets sélectionnés..."
|
||||
label_user_mail_option_none: "Seulement pour ce que je surveille ou à quoi je participe"
|
||||
label_user_mail_no_self_notified: "Je ne veux pas être notifié des changements que j'effectue"
|
||||
label_registration_activation_by_email: activation du compte par email
|
||||
label_registration_manual_activation: activation manuelle du compte
|
||||
label_registration_automatic_activation: activation automatique du compte
|
||||
|
||||
button_login: Connexion
|
||||
button_submit: Soumettre
|
||||
|
|
|
@ -538,3 +538,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -538,3 +538,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -539,3 +539,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -170,7 +170,7 @@ setting_app_subtitle: Application subtitle
|
|||
setting_welcome_text: Welcome text
|
||||
setting_default_language: Default language
|
||||
setting_login_required: Authent. required
|
||||
setting_self_registration: Self-registration enabled
|
||||
setting_self_registration: Self-registration
|
||||
setting_attachment_max_size: Attachment max. size
|
||||
setting_issues_export_limit: Issues export limit
|
||||
setting_mail_from: Emission mail address
|
||||
|
@ -538,3 +538,9 @@ setting_protocol: Protocol
|
|||
mail_body_account_information: Your Redmine account information
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -539,3 +539,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -538,3 +538,9 @@ mail_body_account_information: Twoje konto w Redmine
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -538,3 +538,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -538,3 +538,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -538,3 +538,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -538,3 +538,9 @@ default_activity_development: Разработка
|
|||
enumeration_issue_priorities: Приоритеты задач
|
||||
enumeration_doc_categories: Категории документов
|
||||
enumeration_activities: Действия (учет времени)
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -539,3 +539,9 @@ button_copy: Copy
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -539,3 +539,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -541,3 +541,9 @@ mail_body_account_information: Your Redmine account information
|
|||
setting_protocol: Protocol
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
setting_time_format: Time format
|
||||
label_registration_activation_by_email: account activation by email
|
||||
mail_subject_account_activation_request: Redmine account activation request
|
||||
mail_body_account_activation_request: 'A new user (%s) has registered. His account his pending your approval:'
|
||||
label_registration_automatic_activation: automatic account activation
|
||||
label_registration_manual_activation: manual account activation
|
||||
notice_account_pending: "Your account was created and is now pending administrator approval."
|
||||
|
|
|
@ -56,5 +56,46 @@ class AccountTest < ActionController::IntegrationTest
|
|||
|
||||
log_user('jsmith', 'newpass')
|
||||
assert_equal 0, Token.count
|
||||
end
|
||||
end
|
||||
|
||||
def test_register_with_automatic_activation
|
||||
Setting.self_registration = '3'
|
||||
|
||||
get 'account/register'
|
||||
assert_response :success
|
||||
assert_template 'account/register'
|
||||
|
||||
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
|
||||
:password => "newpass", :password_confirmation => "newpass"
|
||||
assert_redirected_to 'account/login'
|
||||
log_user('newuser', 'newpass')
|
||||
end
|
||||
|
||||
def test_register_with_manual_activation
|
||||
Setting.self_registration = '2'
|
||||
|
||||
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
|
||||
:password => "newpass", :password_confirmation => "newpass"
|
||||
assert_redirected_to 'account/login'
|
||||
assert !User.find_by_login('newuser').active?
|
||||
end
|
||||
|
||||
def test_register_with_email_activation
|
||||
Setting.self_registration = '1'
|
||||
Token.delete_all
|
||||
|
||||
post 'account/register', :user => {:login => "newuser", :language => "en", :firstname => "New", :lastname => "User", :mail => "newuser@foo.bar"},
|
||||
:password => "newpass", :password_confirmation => "newpass"
|
||||
assert_redirected_to 'account/login'
|
||||
assert !User.find_by_login('newuser').active?
|
||||
|
||||
token = Token.find(:first)
|
||||
assert_equal 'register', token.action
|
||||
assert_equal 'newuser@foo.bar', token.user.mail
|
||||
assert !token.expired?
|
||||
|
||||
get 'account/activate', :token => token.value
|
||||
assert_redirected_to 'account/login'
|
||||
log_user('newuser', 'newpass')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue