diff options
author | Sashi20 | 2020-02-20 12:58:59 +0530 |
---|---|---|
committer | Sashi20 | 2020-02-20 12:58:59 +0530 |
commit | 1fb3d381e832d5c5871c6cb2fd8b2c1ae3dbd029 (patch) | |
tree | 3a9829196102efdf509fe50b5458237966999ecf /arduino_blog/decorators.py | |
parent | 802bbc270363d1432cb28cd88d6c9003d8b99b6c (diff) | |
download | arduino_projects_website-1fb3d381e832d5c5871c6cb2fd8b2c1ae3dbd029.tar.gz arduino_projects_website-1fb3d381e832d5c5871c6cb2fd8b2c1ae3dbd029.tar.bz2 arduino_projects_website-1fb3d381e832d5c5871c6cb2fd8b2c1ae3dbd029.zip |
Add user registration, login and abstract submission interfaces
Diffstat (limited to 'arduino_blog/decorators.py')
-rw-r--r-- | arduino_blog/decorators.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/arduino_blog/decorators.py b/arduino_blog/decorators.py new file mode 100644 index 0000000..f7636d8 --- /dev/null +++ b/arduino_blog/decorators.py @@ -0,0 +1,23 @@ +from django.shortcuts import render +from django.conf import settings + +def email_verified(func): + """ + This decorator is used to check if email is verified. + If email is not verified then redirect user for email + verification. + """ + + def is_email_verified(request, *args, **kwargs): + user = request.user + context = {} + if user.is_authenticated: + if not user.profile.is_email_verified: + context['success'] = False + context['msg'] = "Your account is not verified. \ + Please verify your account" + return render( + request, 'activation-status.html', context + ) + return func(request, *args, **kwargs) + return is_email_verified
\ No newline at end of file |