Module: Model::OauthUser::ProgramUser
- Extended by:
- ActiveSupport::Concern
- Included in:
- Wechat::ProgramUser
- Defined in:
- app/models/wechat/model/oauth_user/program_user.rb
Instance Method Summary collapse
Instance Method Details
#auth_token(session_key = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/wechat/model/oauth_user/program_user.rb', line 19 def auth_token(session_key = nil) at = .valid.take || .build at.identity = identity if identity.present? at.session_key = session_key if session_key.present? self.class.transaction do self.save! at.save! end at end |
#get_phone_number(encrypted_data, iv, session_key) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/models/wechat/model/oauth_user/program_user.rb', line 9 def get_phone_number(encrypted_data, iv, session_key) r = Wechat::Cipher.program_decrypt(encrypted_data, iv, session_key) if r['phoneNumber'] r['phoneNumber'] else self.errors.add :base, "手机号获取失败,session_key 为:#{session_key}" nil end end |