def register_done(request):
    global current_session_id
    if request.method=="POST":
        if request.POST['firstname'] and request.POST['lastname'] and request.POST['email'] and request.POST['city'] and request.POST['country']:
            print('Hello')
            user=UserDetails()
            try:
                # check if email is valid or not
                email = request.POST['email']
                try:
                    validate_email(email)
                except ValidationError as e:
                    return render(request,'quiz/register.html',{'error':'Please verify your email.'})
                user.email=email
                user.first_name = request.POST['firstname']
                user.last_name = request.POST['lastname']
                if 'option1' in request.POST:
                    user.gender = "Male"
                elif 'option2' in request.POST:
                    user.gender = "Female"
                else:
                    user.gender = "Other"
                user.city = request.POST['city']
                user.country = request.POST['country']
                user.save()
                current_session_id=user.id
            except ValueError as e:
                return render(request,'quiz/register.html',{'error':'Incorrect values.Please try again.'})

            return render(request,'quiz/thankyou.html')
        else:
            return render(request,'quiz/register.html',{'error':'All fields are required.'})
    else:
        return render(request,'quiz/register.html')
Exemplo n.º 2
0
def register_done(request):

    if request.method == "POST":
        if request.POST['firstname'] and request.POST[
                'lastname'] and request.POST['email'] and request.POST[
                    'city'] and request.POST['country'] and request.POST['age']:
            # print('Hello')
            user = UserDetails()
            try:
                # check if email is valid or not
                email = request.POST['email']
                try:
                    validate_email(email)
                except ValidationError as e:
                    return render(request, 'AllTogether/register.html',
                                  {'error': 'Please verify your email.'})
                user.email = email
                user.first_name = request.POST['firstname']
                user.last_name = request.POST['lastname']
                user.age = request.POST['age']

                option = request.POST.get("option", None)
                if option in ["Male", "Female", "Other"]:
                    if option == "Male":
                        user.gender = "Male"
                    elif option == "Female":
                        user.gender = "Female"
                    elif option == "Other":
                        user.gender = "Other"
                else:
                    return render(request, 'AllTogether/register.html',
                                  {'error': 'All fields are required.'})

                user.city = request.POST['city']
                user.country = request.POST['country']

                if 'terms' not in request.POST:
                    return render(
                        request, 'AllTogether/register.html',
                        {'error': 'Please accept the terms and conditions.'})

                user.save()
                request.session['user_id'] = user.id
                request.session['iteration'] = 1
                request.session['list_of_stimuli'] = []
                request.session['list_of_questions'] = []
                request.session['flag'] = True
            except ValueError as e:
                return render(request, 'AllTogether/register.html',
                              {'error': 'Incorrect values.Please try again.'})

            return render(request,
                          'AllTogether/display_stimuli_instruction.html')
        else:
            return render(request, 'AllTogether/register.html',
                          {'error': 'All fields are required.'})
    else:
        return render(request, 'AllTogether/register.html')
Exemplo n.º 3
0
	def post(self,request):
		data = json.loads(request.body)
		email = data['email']

		if not validate_email(email):
			return JsonResponse({'email_error':'Email is invalid'},status = 400)

		if User.objects.filter(email = email ).exists():
			return JsonResponse({'email_error':'email exists'},status = 409)
		
		return JsonResponse({'email_valid':True})
Exemplo n.º 4
0
    def post(self, email):
        erro = None
        try:
            #função verifier a estrutura e o servidor SMTP (GMAIL, YAHOO, ETC)
            sockes_verifier = Verifier(source_addr=sender_mail)
            results = sockes_verifier.verify(email)
            return results

        except Exception as e:
            ##check_regex checa a estrutura do email esta correta
            ##check_mx: checa se o email existe
            #função da lib validate_email
            is_valid = validate_email(email,
                                      check_mx=True,
                                      smtp_timeout=10,
                                      debug=True)
            print('is_valid:{}'.format(is_valid))
            print("no exception validate email")
            print('o erro foi: {}'.format(e))
            return is_valid, 400
Exemplo n.º 5
0
    def passwordless_signup(self, values):
        qcontext = self.get_auth_signup_qcontext()

        if not values.get("login"):
            return http.request.render("auth_signup.signup", qcontext)

        if not (values.get("login") or values.get("password")
                or values.get("confirm_password")):
            qcontext["error"] = _("Required field are missing.")
            return http.request.render("auth_signup.signup", qcontext)

        # Check field values are valid
        if not validate_email(values.get("login", "")):
            qcontext["error"] = _("That does not seem to be an email address.")
            return http.request.render("auth_signup.signup", qcontext)
        elif values.get("password") != values.get("confirm_password"):
            qcontext["error"] = _(
                "Password and Confirm Password does't match.")
            return http.request.render("auth_signup.signup", qcontext)
        elif not values.get("email"):
            values["email"] = values.get("login")

        sudo_users = (http.request.env["res.users"].with_context(
            create_user=True).sudo())

        try:
            sudo_users.activate_signup(values, qcontext.get("token"))
            sudo_users.account_active(values.get("login"))
        except Exception as error:
            _logger.exception(error)
            http.request.env.cr.rollback()
            qcontext["error"] = _(
                "Something went wrong, please try again later.")
            return http.request.render("auth_signup.signup", qcontext)

        welcome_msg = """Thank you for your registration. \
            An E-Mail has been send to you, kindly authenticate your email address."""
        qcontext["message"] = _(welcome_msg)
        return http.request.render("auth_signup.reset_password", qcontext)
Exemplo n.º 6
0
def validator_email(email_to_val):
    email_validity = validate_email(str(email_to_val))
    if (email_validity == True):
        return True
    elif (email_validity == False):
        return False
Exemplo n.º 7
0
 def credentials_sanity_check(cls, email, password):
     if validate_email(str(email)) and (8 < len(password) < 15):
         return True, {'error': 0}
     else:
         return False, {'error': 1}
Exemplo n.º 8
0
print "<!DOCTYPE html>";
import sys, json, urllib, cgi, os, dbmodule_pg, cgitb, psycopg2,random,time,fish
import validate_email
import hashlib, uuid # these imports are for encrypt password
import smtplib #module use to send activate email
import smtplib
import requests
from validate_email import validate_email
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
#salt = uuid.uuid4().hex
# cgitb use to debug
cgitb.enable()
email = ""
formData = cgi.FieldStorage()
if validate_email(str(formData.getvalue('email'))):
    email = str(formData.getvalue('email'))
else:
    print '<script language="javascript">';
    print 'alert("Invalid email.Now redirecting to login page.")';
    print 'window.location = "http://beelist.agriculture.purdue.edu/lthia/register.html"';
    print '</script>';
password = str(formData.getvalue('password'))
hashed_password = hashlib.md5( fish.salt + password ).hexdigest()
#hashvalue is used to actived the user
hashvalue = ''.join(random.choice('0123456789ABCDEF') for i in range(16))

# configuration for sending activation email

sender = '*****@*****.**'
receivers = [email]