def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): url = "https://na1.api.riotgames.com/lol/summoner/v3/summoners/by-name/" + form.cleaned_data.get( 'in_game_id') + api_key r = requests.get(url) data = r.json() account_id = '0' summoner_id = '0' try: account_id = json.dumps(data['accountId']) summoner_id = json.dumps(data['id']) except KeyError: form.in_game_id = "" return render(request, 'signup.html', {'form': form}) if (account_id == '0' or summoner_id == '0'): form.in_game_id = "" return render(request, 'signup.html', {'form': form}) user = form.save() user.refresh_from_db() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user.profile.in_game_id = form.cleaned_data.get('in_game_id') user.profile.account_id = account_id user.profile.summoner_id = summoner_id user.save() user = authenticate(username=username, password=raw_password) login(request, user) return redirect('index') else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): if request.method == 'POST': #submit form form = SignUpForm(request.POST) if form.is_valid(): #save user model user = form.save(commit=False) user.is_active = False user.save() #save profile model profile = Profile() profile.self_description = form.cleaned_data.get( 'self_description') profile.is_gamer = form.cleaned_data.get('is_gamer') profile.is_developer = form.cleaned_data.get('is_developer') profile.user = user profile.save() current_site = get_current_site(request) #form the link message = render_to_string( 'registration/activation.html', { 'username': user.username, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'usertoken': PasswordResetTokenGenerator().make_token(user) }) subject = 'Your email confirmation link (do NOT reply)' user.email_user(subject, message) return redirect('activation_email_sent') else: #normal access to the page form = SignUpForm() return render(request, 'registration/signup.html', {'form': form})
def register(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): secret_key = form.cleaned_data.get('secret_key') if secret_key == 'corncob-37464': form.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) email = form.cleaned_data.get('email') first_name = form.cleaned_data.get('first_name') last_name = form.cleaned_data.get('last_name') user_name = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = User.objects.create_user(username=user_name, email=email, password=raw_password, first_name=first_name, last_name=last_name) user.save() username = '******' if username != "": gmail_user = '******' gmail_password = '******' sent_from = gmail_user to = '*****@*****.**' body = 'Subject: New User - ' + first_name + ' ' + last_name + '\n\nHi Michael,\n\nA new user has signed up for Tour De Cornfield! \n\nHave a good day! \n\n- Kernel Cob' server = smtplib.SMTP_SSL('smtp.gmail.com', 465) server.ehlo() server.login(gmail_user, gmail_password) server.sendmail(sent_from, to, body) server.close() to = '*****@*****.**' body = 'Subject: New User - ' + first_name + ' ' + last_name + '\n\nHi Hogan,\n\nA new user has signed up for Tour De Cornfield! \n\nHave a good day! \n\n- Kernel Cob' server = smtplib.SMTP_SSL('smtp.gmail.com', 465) server.ehlo() server.login(gmail_user, gmail_password) server.sendmail(sent_from, to, body) server.close() gmail_user = '******' gmail_password = '******' sent_from = gmail_user to = email body = 'Subject: Tour De Cornfield Signup\n\nHi ' + first_name + ',\n\nThank you for signing up for the Tour De Cornfield 2018 Edition! Within the next couple weeks additional features will be enabled on tourdecornfield.com that will enable you to upload your rides and track your standings against others competing in the TDC. If you have any questions feel free to reply to this email and we will get back to you as soon as possible. \n\nHave a good day! \n\n- Kernel Cob' server = smtplib.SMTP_SSL('smtp.gmail.com', 465) server.ehlo() server.login(gmail_user, gmail_password) server.sendmail(sent_from, to, body) server.close() return redirect('home') else: return render(request, 'register.html', {'form': form}) else: form = SignUpForm() return render(request, 'register.html', {'form': form})
def signup_view(request): form = SignUpForm() if request.method == "POST": form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') password = form.cleaned_data.get('password1') user = authenticate(username=username, password=password) login(request, user) return redirect('home') return render(request, 'signup.html', {'form': form})
def signUpview(request): if request.method == "POST": form = SignUpForm(request.POST) if form.is_valid(): data = form.cleaned_data CustUser.objects.create_user( username=data["username"], password=data['password'] ) return HttpResponseRedirect(reverse('home')) form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup_view( request ): #function declaration which is used to show signup page to save the information of new user today = datetime.now() if request.method == "POST": signup_form = SignUpForm( request.POST) #save the details in the database if signup_form.is_valid(): username = signup_form.cleaned_data['username'] name = signup_form.cleaned_data['name'] email = signup_form.cleaned_data['email'] password = signup_form.cleaned_data['password'] if set('abcdefghijklmnopqrstuvwxyz').intersection(name) and set( 'abcdefghijklmnopqrstuvwxyz@_1234567890').intersection( username): if len(username) > 4 and len( password ) > 5: #this is for that username should be greater than 4 and pswrd should be greater then 5 user = UserModel(name=name, password=make_password(password), email=email, username=username) user.save() # saves the user information sg = sendgrid.SendGridAPIClient(apikey=(SENDGRID_API_KEY)) from_email = Email("*****@*****.**") to_email = Email(signup_form.cleaned_data['email']) subject = "Welcome " content = Content("text/plain", "Thank you for signing up ") mail = Mail(from_email, subject, to_email, content) response = sg.client.mail.send.post( request_body=mail.get()) print(response.status_code) print(response.body) print(response.headers) ctypes.windll.user32.MessageBoxW( 0, u"successfully signed up", u"success", 0) return render(request, 'login.html') else: ctypes.windll.user32.MessageBoxW( 0, u"invalid enteries. please try again", u"Error", 0) signup_form = SignUpForm() else: ctypes.windll.user32.MessageBoxW(0, u"invalid name/username", u"error", 0) elif request.method == 'GET': signup_form = SignUpForm() return render(request, 'index.html', { 'date_to_show': today, 'form': signup_form })
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('index') else: form = SignUpForm() return render(request, 'registration/signup.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') password = form.cleaned_data.get('password1') user = authenticate(username=username, password=password) return redirect(reverse('myapp:base')) else: form = SignUpForm() return render(request, 'myapp/registeration.html', {'form': form})
def register(request): if request.method == 'POST': form = SignUpForm(request.POST, request.FILES) if form.is_valid(): form.save() username = form.cleaned_data.get('username') pwd = form.cleaned_data.get('password1') user = authenticate(username=username, password=pwd) login(request, user) return HttpResponseRedirect(reverse(('myapp:index'))) else: return HttpResponse('Invalid') form = SignUpForm() return render(request, 'myapp/register.html', {'form': form})
def signup_view(request): if request.method == "POST": form= SignUpForm(request.POST) if form.is_valid(): username=form.cleaned_data["susername"] password = form.cleaned_data["spassword"] full_name = form.cleaned_data["full_name"] email = form.cleaned_data["email"] if User.objects.filter(username=username).exists(): messages.info(request, 'Username is taken, Choose any other username') return redirect('index.html') else: user=User(full_name=full_name,password=make_password(password),email=email,username=username) user.save() messages.info(request,'Signup Successfull!!!') return render(request, 'index.html', {'form': form}) else: form=SignUpForm return render(request,"index.html",{"form":form})
def signup_view(request): if request.method == "POST": form = SignUpForm(request.POST) if form.is_valid(): username = form.cleaned_data['username'] name = form.cleaned_data['name'] email = form.cleaned_data['email'] password = form.cleaned_data['password'] user_len=len(username) if user_len<4: print "User name should be atleast four character." # saving data to DB user = UserModel(name=name, password=make_password(password), email=email, username=username) user.save() return render(request, 'success.html') else: form = SignUpForm() return render(request, 'index.html', {'form': form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): username = form.cleaned_data['email'].split("@")[0] user = User.objects.filter(username=username) if len(user) > 0: messages.info( request, 'Email atau username tersebut sudah terdaftar %s' % user[0].email) return redirect('signup') user = form.save() user.username = username user.refresh_from_db() user.is_active = False user.save() subject = 'Konfirmasi pendaftaran Anda di Whizkids.id' message = render_to_string( 'account_activation_email.html', { 'username': user.email.split("@")[0], 'user': user, 'host': 'whizkids.id', #request.get_host(), #TOFIX for docker container 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user), }) #TODO background send_message(user.email, subject, message, message) messages.info( request, 'Silahkan cek email pendaftaran yang baru saja kami kirimkan ke %s' % user.email) return redirect('index') else: form = SignUpForm() return render(request, 'registration/signup.html', {'form': form})
def signup_view(request): # Business Logic starts here if request.method == 'GET': # IF GET REQUEST IS RECIEVED THEN DISPLAY THE SIGNUP FORM # today=datetime.now() form = SignUpForm() # template_name='signup.html' return render(request, 'signup.html', {'form': form}) elif request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): # Checks While Valid Entries Is Performed Or Not username = form.cleaned_data['username'] email = form.cleaned_data['email'] name = form.cleaned_data['name'] password = form.cleaned_data['password'] # here above cleaned_data is used so that data could be extracted in safe manner,checks SQL injections # following code inserts data into database new_user = User(name=name, password=make_password(password), username=username, email=email) new_user.save() # finally saves the data in database # sending welcome Email To User That Have Signup Successfull message = "Welcome!! you Creating Your Account in swatchbharat clean india by dushant kumar.You Have " \ "Successfully Registered.It is correct place for show people about your work how you clean ur india.We Are Happy To Get You" \ "as one of our member " server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login('*****@*****.**', constant) server.sendmail('*****@*****.**', email, message) # WOW!!!SUCCESSFULLY SEND EMAIL TO THE USER WHO HAS SIGNUP.USER CAN CHECK INBOX OR SPAM # THIS IS ACCURATLY WORKING return redirect('/login/') return render(request,'success.html',{'form': form}) return render(request, 'success.html', {'form': form})
def signup_view(request): dict = {} if request.method == "POST": form = SignUpForm(request.POST) if form.is_valid(): username = form.cleaned_data['username'] if len(username) >= 4: name = form.cleaned_data['name'] email = form.cleaned_data['email'] password = form.cleaned_data['password'] if len(password) >= 5: # SQL QUERY user = UserModel(name=name, password=make_password(password), email=email, username=username) user.save() #welcome email to the user for successfully completing the sign up sg = sendgrid.SendGridAPIClient(apikey=sendgrid_api) from_email = Email("*****@*****.**") to_email = Email(email) subject = "Upload to win" content = Content("text/plain", "you are successfully signed up!! Enjoy") mail = Mail(from_email, subject, to_email, content) sg.client.mail.send.post(request_body=mail.get()) return render(request, 'success.html') else: dict['message'] = "Password to be at least 5 characters long !" else: dict['message'] = "Username to be at least 4 characters long !" else: dict['message'] = "Invalid Fields! Re-enter above fields." #dict['message'] = form.errors else: form = SignUpForm() dict['form'] = form return render(request, 'index.html', dict)
def signup(request): # If a form is submitted if request.method == 'POST': form = SignUpForm(request.POST) # Check if the form is valid if form.is_valid(): user = form.save() user.refresh_from_db( ) # load the profile instance created by the signal # Adding the address inputs address = Address.objects.create( user=user.profile, address_line_1=form.cleaned_data.get('address_line_1'), address_line_2=form.cleaned_data.get('address_line_2'), city=form.cleaned_data.get('city'), country=form.cleaned_data.get('country'), zip_code=form.cleaned_data.get('zip_code'), ) # Save the birthdate user.profile.birth_date = form.cleaned_data.get("birth_date") address.save() user.save() raw_password = form.cleaned_data.get('password1') # Login the new user user = authenticate(username=user.username, password=raw_password) login(request, user) return redirect('home') # If a form has not yet been submitted, then display an empty form else: form = SignUpForm() return render(request, 'signup.html', {'form': form})
def signup(request): form = SignUpForm() login_form = SignInForm() user_count = User.objects.filter(is_active=True).count() tournaments = Tournament.objects.all().order_by('-created_at') p_user = '' if not request.user.is_anonymous: p_user = PUser.objects.filter(user=request.user).get() if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() user = User.objects.get(username=request.POST['username']) PUser.objects.create(user=user) uidb64 = urlsafe_base64_encode(force_bytes(user.id)) domain = get_current_site(request).domain activate_url = 'http://' + domain + '/activate/' + uidb64 + '/' + token_generator.make_token( user) subject = 'Activate your account' message = 'Hi ' + user.username + '\nPlease use this link to verify your account\n' + activate_url from_email = settings.EMAIL_HOST_USER to_list = [user.email] send_mail(subject, message, from_email, to_list, fail_silently=False) return render( request, 'myapp/index.html', { 'form': form, 'login_form': login_form, 'user_count': user_count, 'tournaments': tournaments, 'p_user': p_user })