Skip to content

Docs: harmonize examples & clarify when to use setup_activation (recommended in README but not in the Wiki) #328

@jankoegel

Description

@jankoegel

Configuration

  • Sorcery Version: latest

Expected Behavior

The docs should be clear and not say two different things in two places.

Actual Behavior

The README recommends the following steps to activate a user:

User.load_from_activation_token(token)
@user.setup_activation
@user.activate!

This suggests that a call to setup_activation is required to activate a user. In the Wiki, however, setup_activation is omitted (and only mentioned at the very bottom in an example for resending the activation email):

if @user = User.load_from_activation_token(params[:id])
  @user.activate!
  redirect_to(login_path, :notice => 'User was successfully activated.')

Source for setup_activation at the time of writing:

def setup_activation
config = sorcery_config
generated_activation_token = TemporaryToken.generate_random_token
send(:"#{config.activation_token_attribute_name}=", generated_activation_token)
send(:"#{config.activation_state_attribute_name}=", 'pending')
send(:"#{config.activation_token_expires_at_attribute_name}=", Time.now.in_time_zone + config.activation_token_expiration_period) if config.activation_token_expiration_period
end

Desired changes

  • clarify in the docs when a call to setup_activation is needed
  • harmonize the examples in the README and the Wiki so no confusion about when it's required to call setup_activation.

Steps to Reproduce

Doesn't apply.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions