Skip to content

Commit d34d19d

Browse files
committed
Added flask limits and fixed some messages
1 parent 436fc9f commit d34d19d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lms/lmsweb/views.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def login(login_message: Optional[str] = None):
116116

117117

118118
@webapp.route('/signup', methods=['GET', 'POST'])
119+
@limiter.limit(f'{LIMITS_PER_MINUTE}/minute;{LIMITS_PER_HOUR}/hour')
119120
def signup():
120121
if not webapp.config.get('REGISTRATION_OPEN', False):
121122
return redirect(url_for(
@@ -141,13 +142,14 @@ def signup():
141142

142143

143144
@webapp.route('/confirm-email/<int:user_id>/<token>')
145+
@limiter.limit(f'{LIMITS_PER_MINUTE}/minute;{LIMITS_PER_HOUR}/hour')
144146
def confirm_email(user_id: int, token: str):
145147
user = User.get_or_none(User.id == user_id)
146148
if user is None:
147-
return fail(404, f'No such user with id {user_id}.')
149+
return fail(404, f'The authentication code is invalid.')
148150

149151
if not user.role.is_unverified:
150-
return fail(403, f'User has been already confirmed {user.username}')
152+
return fail(403, f'User has been already confirmed.')
151153

152154
try:
153155
SERIALIZER.loads(
@@ -162,7 +164,7 @@ def confirm_email(user_id: int, token: str):
162164
),
163165
))
164166
except BadSignature:
165-
return fail(404, 'No such signature')
167+
return fail(404, 'The authentication code is invalid.')
166168

167169
else:
168170
update = User.update(

lms/templates/login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h1 id="main-title" class="h3 font-weight-normal">{{ _('התחברות') }}</h1>
3535
<button class="btn btn-primary btn-lg btn-block">{{ _('התחבר') }}</button>
3636
</form>
3737
{% if config.REGISTRATION_OPEN %}
38-
<hr class="mt-3 mb-3"/>
38+
<hr class="mt-3 mb-3">
3939
<a href="/signup" class="btn btn-success btn-sm" role="button">{{ _('הירשם') }}</a>
4040
{% endif %}
4141
</div>

0 commit comments

Comments
 (0)