Class: TinyPassport::Oauth::LoginDisconnectForm

Inherits:
Object
  • Object
show all
Includes:
Formable
Defined in:
app/forms/tiny_passport/oauth/login_disconnect_form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



7
8
9
# File 'app/forms/tiny_passport/oauth/login_disconnect_form.rb', line 7

def 
  @account
end

#oauth_login_idObject (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
end

Instance Method Details

#oauth_loginObject



27
28
29
# File 'app/forms/tiny_passport/oauth/login_disconnect_form.rb', line 27

def 
  @oauth_login ||= ::TinyPassport::OauthLogin.where(:id => self.).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..destroy!
    end
  else
    false
  end
end

#verify_paramsObject

校验参数



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.
    if self.
      if self..id != self..
        self.errors.add :oauth_login_id, :wrong
      end
    end
  else
    self.errors.add :oauth_login_id, :not_found
  end

  unless self.
    self.errors.add :account, :required
  end
end