##// END OF EJS Templates
db-models: added some helpers for auth, and external identity code.
marcink -
r3251:be2709fe default
parent child Browse files
Show More
@@ -377,6 +377,12 b' class RhodeCodeSetting(Base, BaseModel):'
377 % (self.SETTINGS_TYPES.keys(), val))
377 % (self.SETTINGS_TYPES.keys(), val))
378 self._app_settings_type = val
378 self._app_settings_type = val
379
379
380 @classmethod
381 def get_by_prefix(cls, prefix):
382 return RhodeCodeSetting.query()\
383 .filter(RhodeCodeSetting.app_settings_name.startswith(prefix))\
384 .all()
385
380 def __unicode__(self):
386 def __unicode__(self):
381 return u"<%s('%s:%s[%s]')>" % (
387 return u"<%s('%s:%s[%s]')>" % (
382 self.__class__.__name__,
388 self.__class__.__name__,
@@ -4143,20 +4149,16 b' class ExternalIdentity(Base, BaseModel):'
4143 base_table_args
4149 base_table_args
4144 )
4150 )
4145
4151
4146 external_id = Column('external_id', Unicode(255), default=u'',
4152 external_id = Column('external_id', Unicode(255), default=u'', primary_key=True)
4147 primary_key=True)
4148 external_username = Column('external_username', Unicode(1024), default=u'')
4153 external_username = Column('external_username', Unicode(1024), default=u'')
4149 local_user_id = Column('local_user_id', Integer(),
4154 local_user_id = Column('local_user_id', Integer(), ForeignKey('users.user_id'), primary_key=True)
4150 ForeignKey('users.user_id'), primary_key=True)
4155 provider_name = Column('provider_name', Unicode(255), default=u'', primary_key=True)
4151 provider_name = Column('provider_name', Unicode(255), default=u'',
4152 primary_key=True)
4153 access_token = Column('access_token', String(1024), default=u'')
4156 access_token = Column('access_token', String(1024), default=u'')
4154 alt_token = Column('alt_token', String(1024), default=u'')
4157 alt_token = Column('alt_token', String(1024), default=u'')
4155 token_secret = Column('token_secret', String(1024), default=u'')
4158 token_secret = Column('token_secret', String(1024), default=u'')
4156
4159
4157 @classmethod
4160 @classmethod
4158 def by_external_id_and_provider(cls, external_id, provider_name,
4161 def by_external_id_and_provider(cls, external_id, provider_name, local_user_id=None):
4159 local_user_id=None):
4160 """
4162 """
4161 Returns ExternalIdentity instance based on search params
4163 Returns ExternalIdentity instance based on search params
4162
4164
@@ -4198,6 +4200,13 b' class ExternalIdentity(Base, BaseModel):'
4198 query = query.filter(cls.local_user_id == local_user_id)
4200 query = query.filter(cls.local_user_id == local_user_id)
4199 return query
4201 return query
4200
4202
4203 @classmethod
4204 def load_provider_plugin(cls, plugin_id):
4205 from rhodecode.authentication.base import loadplugin
4206 _plugin_id = 'egg:rhodecode-enterprise-ee#{}'.format(plugin_id)
4207 auth_plugin = loadplugin(_plugin_id)
4208 return auth_plugin
4209
4201
4210
4202 class Integration(Base, BaseModel):
4211 class Integration(Base, BaseModel):
4203 __tablename__ = 'integrations'
4212 __tablename__ = 'integrations'
General Comments 0
You need to be logged in to leave comments. Login now