oneclickorgs / one-click-orgs

Create legal organisations with just one click
http://oneclickorgs.com/
GNU Affero General Public License v3.0
45 stars 13 forks source link

A StateMachine::InvalidTransition occurred in invitations#update: #460

Closed chrismear closed 10 years ago

chrismear commented 10 years ago
 Cannot transition state via :induct from :active (Reason(s): State cannot transition via "induct")
 state_machine (1.2.0) lib/state_machine/event.rb:252:in `block in add_actions'

state_machine (1.2.0) lib/state_machine/event.rb:252:in `block in add_actions'
 state_machine (1.2.0) lib/state_machine/machine.rb:765:in `call'
 state_machine (1.2.0) lib/state_machine/machine.rb:765:in `block (2 levels) in define_helper'
 app/models/invitation.rb:31:in `save'
 lib/one_click_orgs/model_wrapper.rb:45:in `update_attributes'
 app/controllers/invitations_controller.rb:21:in `update'
 actionpack (3.2.16) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
 actionpack (3.2.16) lib/abstract_controller/base.rb:167:in `process_action'
 actionpack (3.2.16) lib/action_controller/metal/rendering.rb:10:in `process_action'
 actionpack (3.2.16) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
 activesupport (3.2.16) lib/active_support/callbacks.rb:469:in `_run__3641328436821576642__process_action__2773595737011797334__callbacks'
 activesupport (3.2.16) lib/active_support/callbacks.rb:405:in `__run_callback'
 activesupport (3.2.16) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
 activesupport (3.2.16) lib/active_support/callbacks.rb:81:in `run_callbacks'
 actionpack (3.2.16) lib/abstract_controller/callbacks.rb:17:in `process_action'
 actionpack (3.2.16) lib/action_controller/metal/rescue.rb:29:in `process_action'
 actionpack (3.2.16) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
 activesupport (3.2.16) lib/active_support/notifications.rb:123:in `block in instrument'
 activesupport (3.2.16) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
 activesupport (3.2.16) lib/active_support/notifications.rb:123:in `instrument'
 actionpack (3.2.16) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
 actionpack (3.2.16) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
 activerecord (3.2.16) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
 actionpack (3.2.16) lib/abstract_controller/base.rb:121:in `process'
 actionpack (3.2.16) lib/abstract_controller/rendering.rb:45:in `process'
 actionpack (3.2.16) lib/action_controller/metal.rb:203:in `dispatch'
 actionpack (3.2.16) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
 actionpack (3.2.16) lib/action_controller/metal.rb:246:in `block in action'
 actionpack (3.2.16) lib/action_dispatch/routing/route_set.rb:73:in `call'
 actionpack (3.2.16) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
 actionpack (3.2.16) lib/action_dispatch/routing/route_set.rb:36:in `call'
 journey (1.0.4) lib/journey/router.rb:68:in `block in call'
 journey (1.0.4) lib/journey/router.rb:56:in `each'
 journey (1.0.4) lib/journey/router.rb:56:in `call'
 actionpack (3.2.16) lib/action_dispatch/routing/route_set.rb:608:in `call'
 exception_notification_rails3 (1.2.0) lib/exception_notifier.rb:34:in `call'
 actionpack (3.2.16) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
 rack (1.4.5) lib/rack/etag.rb:23:in `call'
 rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'
 actionpack (3.2.16) lib/action_dispatch/middleware/head.rb:14:in `call'
 actionpack (3.2.16) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
 actionpack (3.2.16) lib/action_dispatch/middleware/flash.rb:242:in `call'
 rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
 rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
 actionpack (3.2.16) lib/action_dispatch/middleware/cookies.rb:341:in `call'
 activerecord (3.2.16) lib/active_record/query_cache.rb:64:in `call'
 activerecord (3.2.16) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
 actionpack (3.2.16) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
 activesupport (3.2.16) lib/active_support/callbacks.rb:405:in `_run__978430174551070178__call__1808276805474447693__callbacks'
 activesupport (3.2.16) lib/active_support/callbacks.rb:405:in `__run_callback'
 activesupport (3.2.16) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
 activesupport (3.2.16) lib/active_support/callbacks.rb:81:in `run_callbacks'
 actionpack (3.2.16) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
 rack (1.4.5) lib/rack/sendfile.rb:102:in `call'
 actionpack (3.2.16) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
 actionpack (3.2.16) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
 actionpack (3.2.16) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
 railties (3.2.16) lib/rails/rack/logger.rb:32:in `call_app'
 railties (3.2.16) lib/rails/rack/logger.rb:16:in `block in call'
 activesupport (3.2.16) lib/active_support/tagged_logging.rb:22:in `tagged'
 railties (3.2.16) lib/rails/rack/logger.rb:16:in `call'
 actionpack (3.2.16) lib/action_dispatch/middleware/request_id.rb:22:in `call'
 rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
 rack (1.4.5) lib/rack/runtime.rb:17:in `call'
 activesupport (3.2.16) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
 rack (1.4.5) lib/rack/lock.rb:15:in `call'
 actionpack (3.2.16) lib/action_dispatch/middleware/static.rb:63:in `call'
 rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
 rack-cache (1.2) lib/rack/cache/context.rb:143:in `pass'
 rack-cache (1.2) lib/rack/cache/context.rb:155:in `invalidate'
 rack-cache (1.2) lib/rack/cache/context.rb:71:in `call!'
 rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
 railties (3.2.16) lib/rails/engine.rb:484:in `call'
 railties (3.2.16) lib/rails/application.rb:231:in `call'
 rack (1.4.5) lib/rack/content_length.rb:14:in `call'
 railties (3.2.16) lib/rails/rack/log_tailer.rb:17:in `call'
 rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
 /home/oneclickorgs/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
 /home/oneclickorgs/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
 /home/oneclickorgs/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
chrismear commented 10 years ago

This is something to do with the invitation system. The way it's supposed to work is:

If the member then tries to use their invitation link again, the system should not find the member record because the invitation code has been cleared, and so it should take them to the home page to log in instead.

My hunch is that, for some reason, the invitation code is not being cleared when the invitation is accepted. So, if a member tries to use their invitation link again, the app finds the member record, and starts trying to take the user through the sign-up process again. But this then fails, since you can't move a member from 'active' to 'active', resulting in the error above.

So we need two fixes. First, make sure the invitation code actually gets cleared. Second, adjust the invitation flow so that if it finds a member that is already active, it doesn't try to go through the invitation process again; it just takes them straight to the login screen.

chrismear commented 10 years ago

Fixes applied to master and coop branches.