def regenerate_bot_api_key(request: HttpRequest, user_profile: UserProfile, bot_id: int) -> HttpResponse: bot = access_bot_by_id(user_profile, bot_id) do_regenerate_api_key(bot, user_profile) json_result = dict(api_key=bot.api_key) return json_success(json_result)
def regenerate_api_key(request, user_profile): # type: (HttpRequest, UserProfile) -> HttpResponse do_regenerate_api_key(user_profile, user_profile) json_result = dict( api_key = user_profile.api_key ) return json_success(json_result)
def regenerate_api_key(request, user_profile): # type: (HttpRequest, UserProfile) -> HttpResponse do_regenerate_api_key(user_profile) json_result = dict( api_key = user_profile.api_key ) return json_success(json_result)
def test_regenerate_api_key(self) -> None: now = timezone_now() user = self.example_user('hamlet') do_regenerate_api_key(user, user) self.assertEqual(RealmAuditLog.objects.filter(event_type=RealmAuditLog.USER_API_KEY_CHANGED, event_time__gte=now).count(), 1) self.assertTrue(user.api_key)
def regenerate_bot_api_key(request: HttpRequest, user_profile: UserProfile, bot_id: int) -> HttpResponse: bot = access_bot_by_id(user_profile, bot_id) do_regenerate_api_key(bot, user_profile) json_result = dict( api_key = bot.api_key ) return json_success(json_result)
def test_regenerate_api_key(self): # type: () -> None now = timezone_now() user = self.example_user('hamlet') do_regenerate_api_key(user, user) self.assertEqual(RealmAuditLog.objects.filter(event_type='user_api_key_changed', event_time__gte=now).count(), 1) self.assertTrue(user.api_key)
def test_regenerate_api_key(self): # type: () -> None now = timezone_now() user = self.example_user('hamlet') do_regenerate_api_key(user, user) self.assertEqual( RealmAuditLog.objects.filter(event_type='user_api_key_changed', event_time__gte=now).count(), 1) self.assertTrue(user.api_key)
def regenerate_bot_api_key(request, user_profile, email): try: bot = get_user_profile_by_email(email) except: return json_error('No such user') if not user_profile.can_admin_user(bot): return json_error('Insufficient permission') do_regenerate_api_key(bot) json_result = dict(api_key=bot.api_key) return json_success(json_result)
def regenerate_bot_api_key(request: HttpRequest, user_profile: UserProfile, email: Text) -> HttpResponse: try: bot = get_user(email, user_profile.realm) except UserProfile.DoesNotExist: return json_error(_('No such user')) if not user_profile.can_admin_user(bot): return json_error(_('Insufficient permission')) do_regenerate_api_key(bot, user_profile) json_result = dict(api_key=bot.api_key) return json_success(json_result)
def regenerate_bot_api_key(request, user_profile, email): # type: (HttpRequest, UserProfile, text_type) -> HttpResponse try: bot = get_user_profile_by_email(email) except: return json_error(_("No such user")) if not user_profile.can_admin_user(bot): return json_error(_("Insufficient permission")) do_regenerate_api_key(bot) json_result = dict(api_key=bot.api_key) return json_success(json_result)
def regenerate_bot_api_key(request, user_profile, email): # type: (HttpRequest, UserProfile, text_type) -> HttpResponse try: bot = get_user_profile_by_email(email) except: return json_error(_('No such user')) if not user_profile.can_admin_user(bot): return json_error(_('Insufficient permission')) do_regenerate_api_key(bot) json_result = dict(api_key=bot.api_key) return json_success(json_result)
def regenerate_bot_api_key(request: HttpRequest, user_profile: UserProfile, email: Text) -> HttpResponse: try: bot = get_user(email, user_profile.realm) except UserProfile.DoesNotExist: return json_error(_('No such user')) if not user_profile.can_admin_user(bot): return json_error(_('Insufficient permission')) do_regenerate_api_key(bot, user_profile) json_result = dict( api_key = bot.api_key ) return json_success(json_result)
def regenerate_bot_api_key(request, user_profile, email): try: bot = get_user_profile_by_email(email) except: return json_error('No such user') if not user_profile.can_admin_user(bot): return json_error('Insufficient permission') do_regenerate_api_key(bot) json_result = dict( api_key = bot.api_key ) return json_success(json_result)
def regenerate_api_key(request: HttpRequest, user_profile: UserProfile) -> HttpResponse: new_api_key = do_regenerate_api_key(user_profile, user_profile) if new_api_key: json_success_result = { api_key = new_api_key, } return json_success(json_result) else: json_error_result = { "msg" : "Permission denied.", "status": 409, } return json_error(**json_error_result)
def test_regenerate_bot_api_key(self): action = lambda: do_regenerate_api_key(self.bot) events = self.do_test(action) error = self.realm_bot_schema('api_key', check_string)('events[0]', events[0]) self.assert_on_error(error)
def regenerate_api_key(request, user_profile): do_regenerate_api_key(user_profile) json_result = dict(api_key=user_profile.api_key) return json_success(json_result)
def regenerate_api_key(request, user_profile): do_regenerate_api_key(user_profile) json_result = dict( api_key = user_profile.api_key ) return json_success(json_result)
def regenerate_api_key(request: HttpRequest, user_profile: UserProfile) -> HttpResponse: new_api_key = do_regenerate_api_key(user_profile, user_profile) json_result = dict(api_key=new_api_key, ) return json_success(json_result)