##// END OF EJS Templates
authentication: allow setting extern type with registration....
marcink -
r3255:f80876b0 default
parent child Browse files
Show More
@@ -273,16 +273,26 b' class LoginView(BaseAppView):'
273 273 route_name='register', request_method='POST',
274 274 renderer='rhodecode:templates/register.mako')
275 275 def register_post(self):
276 from rhodecode.authentication.plugins import auth_rhodecode
277
276 278 self.load_default_context()
277 279 captcha = self._get_captcha_data()
278 280 auto_active = 'hg.register.auto_activate' in User.get_default_user()\
279 281 .AuthUser().permissions['global']
280 282
283 extern_name = auth_rhodecode.RhodeCodeAuthPlugin.uid
284 extern_type = auth_rhodecode.RhodeCodeAuthPlugin.uid
285
281 286 register_form = RegisterForm(self.request.translate)()
282 287 try:
283 288
284 289 form_result = register_form.to_python(self.request.POST)
285 290 form_result['active'] = auto_active
291 external_identity = self.request.POST.get('external_identity')
292
293 if external_identity:
294 extern_name = external_identity
295 extern_type = external_identity
286 296
287 297 if captcha.active:
288 298 captcha_status, captcha_message = self.validate_captcha(
@@ -295,11 +305,17 b' class LoginView(BaseAppView):'
295 305 raise formencode.Invalid(
296 306 _msg, _value, None, error_dict=error_dict)
297 307
298 new_user = UserModel().create_registration(form_result)
308 new_user = UserModel().create_registration(
309 form_result, extern_name=extern_name, extern_type=extern_type)
299 310
300 311 action_data = {'data': new_user.get_api_data(),
301 312 'user_agent': self.request.user_agent}
302 313
314
315
316 if external_identity:
317 action_data['external_identity'] = external_identity
318
303 319 audit_user = audit_logger.UserWrap(
304 320 username=new_user.username,
305 321 user_id=new_user.user_id,
@@ -344,8 +344,8 b' class UserModel(BaseModel):'
344 344 new_user.is_new_user = not edit
345 345 # for users that didn's specify auth type, we use RhodeCode built in
346 346 from rhodecode.authentication.plugins import auth_rhodecode
347 extern_name = extern_name or auth_rhodecode.RhodeCodeAuthPlugin.name
348 extern_type = extern_type or auth_rhodecode.RhodeCodeAuthPlugin.name
347 extern_name = extern_name or auth_rhodecode.RhodeCodeAuthPlugin.uid
348 extern_type = extern_type or auth_rhodecode.RhodeCodeAuthPlugin.uid
349 349
350 350 try:
351 351 new_user.username = username
@@ -392,14 +392,15 b' class UserModel(BaseModel):'
392 392 log.error(traceback.format_exc())
393 393 raise
394 394
395 def create_registration(self, form_data):
395 def create_registration(self, form_data,
396 extern_name='rhodecode', extern_type='rhodecode'):
396 397 from rhodecode.model.notification import NotificationModel
397 398 from rhodecode.model.notification import EmailNotificationModel
398 399
399 400 try:
400 401 form_data['admin'] = False
401 form_data['extern_name'] = 'rhodecode'
402 form_data['extern_type'] = 'rhodecode'
402 form_data['extern_name'] = extern_name
403 form_data['extern_type'] = extern_type
403 404 new_user = self.create(form_data)
404 405
405 406 self.sa.add(new_user)
General Comments 0
You need to be logged in to leave comments. Login now