示例#1
0
文件: users.py 项目: zeroyou/zulip
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)
示例#2
0
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)
示例#3
0
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)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
文件: users.py 项目: BakerWang/zulip
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)
示例#7
0
 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)
示例#8
0
 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)
示例#9
0
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)
示例#10
0
文件: users.py 项目: wangjames/zulip
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)
示例#11
0
文件: users.py 项目: rlugojr/zulip
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)
示例#12
0
文件: users.py 项目: shekhirin/zulip
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)
示例#13
0
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)
示例#14
0
文件: users.py 项目: 8trust/zulip
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)
示例#15
0
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)
示例#16
0
 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)
示例#17
0
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)
示例#18
0
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)
示例#19
0
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)
示例#20
0
 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)