diff options
author | Prashant S | 2020-02-27 17:21:19 +0530 |
---|---|---|
committer | GitHub | 2020-02-27 17:21:19 +0530 |
commit | 61c91c743fabb5c31127e8f8a8109364eda9b8ff (patch) | |
tree | d7a1e70ff6bc1fe40ab580326bd92b6f6807e205 /arduino_blog/decorators.py | |
parent | 802bbc270363d1432cb28cd88d6c9003d8b99b6c (diff) | |
parent | e1fe11723b0d064684137667ba40c32df34483ed (diff) | |
download | arduino_projects_website-61c91c743fabb5c31127e8f8a8109364eda9b8ff.tar.gz arduino_projects_website-61c91c743fabb5c31127e8f8a8109364eda9b8ff.tar.bz2 arduino_projects_website-61c91c743fabb5c31127e8f8a8109364eda9b8ff.zip |
Merge pull request #1 from prashantsinalkar/master
updated ui and code
Diffstat (limited to 'arduino_blog/decorators.py')
-rw-r--r-- | arduino_blog/decorators.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/arduino_blog/decorators.py b/arduino_blog/decorators.py new file mode 100644 index 0000000..ddb888c --- /dev/null +++ b/arduino_blog/decorators.py @@ -0,0 +1,26 @@ +from django.shortcuts import render, redirect +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 = {} + try: + 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) + except: + return redirect('/') + return is_email_verified |