Class: TinyPassport::Oauth::LoginDisconnectForm
- Inherits:
-
Object
- Object
- TinyPassport::Oauth::LoginDisconnectForm
- Includes:
- Formable
- Defined in:
- app/forms/tiny_passport/oauth/login_disconnect_form.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#oauth_login_id ⇒ Object
readonly
Returns the value of attribute oauth_login_id.
Instance Method Summary collapse
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
7 8 9 |
# File 'app/forms/tiny_passport/oauth/login_disconnect_form.rb', line 7 def account @account end |
#oauth_login_id ⇒ Object (readonly)
Returns the value of attribute oauth_login_id.
7 8 9 |
# File 'app/forms/tiny_passport/oauth/login_disconnect_form.rb', line 7 def oauth_login_id @oauth_login_id end |
Instance Method Details
#oauth_login ⇒ Object
27 28 29 |
# File 'app/forms/tiny_passport/oauth/login_disconnect_form.rb', line 27 def oauth_login @oauth_login ||= ::TinyPassport::OauthLogin.where(:id => self.oauth_login_id).first end |
#submit(params = {}) ⇒ Object
提交
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/forms/tiny_passport/oauth/login_disconnect_form.rb', line 14 def submit params={} @oauth_login_id = params[:oauth_login_id] @account = params[:account] if self.valid? && self.success? ::ActiveRecord::Base.transaction do self.oauth_login.destroy! end else false end end |
#verify_params ⇒ Object
校验参数
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/forms/tiny_passport/oauth/login_disconnect_form.rb', line 32 def verify_params if self.oauth_login if self.account if self.account.id != self.oauth_login.account_id self.errors.add :oauth_login_id, :wrong end end else self.errors.add :oauth_login_id, :not_found end unless self.account self.errors.add :account, :required end end |