lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt in authentication-zero-1.0.2 vs lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt in authentication-zero-2.0.0

- old
+ new

@@ -7,17 +7,23 @@ def create @<%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>) if @<%= singular_table_name %>.save - cookies.signed[:session_token] = { value: @<%= singular_table_name %>.session_token, httponly: true } + @session = @user.sessions.create!(session_params) + cookies.signed.permanent[:session_token] = { value: @session.id, httponly: true } + redirect_to root_path, notice: "Welcome! You have signed up successfully" else render :new, status: :unprocessable_entity end end private def <%= "#{singular_table_name}_params" %> params.require(:<%= singular_table_name %>).permit(:email, :password, :password_confirmation) + end + + def session_params + { user_agent: request.user_agent, ip_address: request.remote_ip } end end