app/models/ibrain/auth/user.rb in ibrain-auth-0.3.1 vs app/models/ibrain/auth/user.rb in ibrain-auth-0.3.2

- old
+ new

@@ -11,10 +11,14 @@ devise :database_authenticatable, :registerable, :confirmable, :recoverable, :validatable, :timeoutable, :jwt_authenticatable, jwt_revocation_strategy: self + scope :find_by_line, ->(uid) { + find_by(uid: uid, provider: 'line') + } + def jwt_payload # for hasura hasura_keys = { 'https://hasura.io/jwt/claims': { 'x-hasura-allowed-roles': Ibrain.user_class.roles.keys, @@ -44,9 +48,17 @@ def social_find_or_initialize(params) user = find_by(provider: params[:provider], uid: params[:uid]) return user if user.present? create!(params) + end + + def create_with_line!(params) + created!({ + uid: params['uid'], + provider: 'line', + remote_avatar_url: params['info']['image'] + }) end end end end end