Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scottmotte-merb-auth-slice-password-reset

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scottmotte-merb-auth-slice-password-reset

  • 0.9.14
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

h3. MerbAuthSliceActivation

This slice provides a check to make sure that a user is active on login. It also provides activation on the "user" object via an activation action (slice_url :activate). When loggin in, the "user" object found by merb-auth-core will be asked

Do you respond_to?(:active?):

If yes, check if active and return the user if they are

If no, return the user (i.e. no activation check)

This slice adds a mixin that you should include in your user model to priovide the active? method. The mixin will automatically select the correct sub mixin for all supported orms.


class User
  include DataMapper::Resource
  include Merb::Authentication::Mixins::SenileUser

  property :id,    Serial
end

The mixin provides a number of methods. The most common are:


  @user.activate    # activates (and saves) the user
  @user.activated?  # Returns the "active" status of the user
  @user.active?     # Alias for activated?

h3. Migration Requirements

The mixin requires some fields to be in-place on your model. Where needed include these in your migrations.


  :password_reset_code, String

h3. Mailers

The slice contains 2 mailing actions that are setup as callback hooks on the model. When the model is created a "signup" email is sent with the link to follow to activate the account. Also an activation acknowledgment email.

h3. Configuration Options

These options may be declared in your @init.rb@ or @environment/*.rb@ files

Use the standard slice configuration hash to set these up @Merb::Slices::config[:'merb-auth-slice-activation']@

h4. Required

:from_email # The email account to send the email from :activation_host # The host to go to for activation. This is used to construct the # activation link. Symbol, String or Procs are available. # Procs will have the @user@ object passed in

h4. Optional

:welcome_subject # The subject of the email to send after activation (Welcome)

h3. Customizing the emails

To customize your emails, rake the slices stubs


	$ rake slices:merb-auth-slice-activation:stubs

This will create stubs of the views in @slices/merb-auth-slice-activation/app/mailers/views/@

To create HTML emails just add an html template like @signup.html.erb@

h3. Customize the Redirect after activation

rake the slices stubs as above. There is an @activations.rb@ controller in the @slices/merb-auth-slice-activation/app/controllers@ directory. You can overwrite the stubbed method in there to have it change it's redirection behavior.

Rake tasks to package/install the gem - edit this to modify the manifest.

The slice application: controllers, models, helpers, views.

The default layout, as specified in @Merb::Slices::config[:'merb-auth-slice-activation'][:layout]@ change this to :application to use the app's layout.

Standard rake tasks available to your application.

Your custom application rake tasks.

The main slice file - contains all slice setup @logic/config@.

Public assets you (optionally) install using @rake slices:merb-auth-slice-activation:install@

Specs for basis slice behaviour - you usually adapt these for your slice.

Stubs of classes/views/files for the end-user to override - usually these mimic the files in @app/@ and/or @public/@; use @rake slices:merb-auth-slice-activation:stubs@ to get started with the override stubs. Also, @rake slices:merb-auth-slice-activation:patch@ will copy over views to override in addition to the files found in /stubs.

To see all available tasks for MerbAuthSliceActivation run:


	$ rake -T slices:merb_auth_slice_password_reset

h3. Instructions for installation:

h4. @config/init.rb@

Add the slice as a regular dependency


	dependency 'merb-auth-slice-password-reset'

If needed, configure which slices to load and in which order


	Merb::Plugins.config[:merb_slices] = { :queue => ["MerbAuthSlicePasswordReset", ...] }

Optionally configure the plugins in a before_app_loads callback


	Merb::BootLoader.before_app_loads do

	  Merb::Slices::config[:merb_auth_slice_password_reset][:option] = value

	end

h4. @config/router.rb@

Example: /merb_auth_slice_password_reset/:controller/:action/:id


	add_slice(:MerbAuthSlicePasswordReset)

Example: /foo/:controller/:action/:id


	add_slice(:MerbAuthSlicePasswordReset, 'foo') # same as :path => 'foo'

Example: /:lang/:controller/:action/:id


	add_slice(:MerbAuthSlicePasswordReset, :path => ':lang')

Example: /:controller/:action/:id


	slice(:MerbAuthSlicePasswordReset)

Normally you should also run the following rake task:


	$ rake slices:merb_auth_slice_password_reset:install

h4. Overrides

You can put your application-level overrides in:

host-app/slices/merb-auth-slice-password-reset/app - controllers, models, views ...

Templates are located in this order:

host-app/slices/merb-auth-slice-password-reset/app/views/*

gems/merb-auth-slice-password-reset/app/views/*

host-app/app/views/*

You can use the host application's layout by configuring the merb-auth-slice-password-reset slice in a before_app_loads block:


	Merb::Slices.config[:merb_auth_slice_password_reset] = { :layout => :application }

By default :merb_auth_slice_password_reset is used. If you need to override stylesheets or javascripts, just specify your own files in your layout instead/in addition to the ones supplied (if any) in host-app/public/slices/merb-auth-slice-password-reset.

In any case don't edit those files directly as they may be clobbered any time rake merb_auth_slice_password_reset:install is run.

h3. About Slices

Merb-Slices is a Merb plugin for using and creating application 'slices' which help you modularize your application. Usually these are reuseable extractions from your main app. In effect, a Slice is just like a regular Merb MVC application, both in functionality as well as in structure.

When you generate a Slice stub structure, a module is setup to serve as a namespace for your controller, models, helpers etc. This ensures maximum encapsulation. You could say a Slice is a mixture between a Merb plugin (a Gem) and a Merb application, reaping the benefits of both.

A host application can 'mount' a Slice inside the router, which means you have full over control how it integrates. By default a Slice's routes are prefixed by its name (a router :namespace), but you can easily provide your own prefix or leave it out, mounting it at the root of your url-schema. You can even mount a Slice multiple times and give extra parameters to customize an instance's behaviour.

A Slice's Application controller uses controller_for_slice to setup slice specific behaviour, which mainly affects cascaded view handling. Additionaly, this method is available to any kind of controller, so it can be used for Merb Mailer too for example.

There are many ways which let you customize a Slice's functionality and appearance without ever touching the Gem-level code itself. It's not only easy to add template/layout overrides, you can also add/modify controllers, models and other runtime code from within the host application.

To create your own Slice run this (somewhere outside of your merb app):


	$ merb-gen slice 

FAQs

Package last updated on 10 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc