def form_valid(self, form): """ Validated form and send email. """ user = User.objects.get(email=form.cleaned_data['email']) # Generate unique key to reset password key = generate_hash_key(user.username) reset_password = PasswordReset(user=user, key=key) reset_password.save() # Send email send_email_template( subject=_('Requesting new password'), template='accounts/reset_password_email.html', context={'reset_password': reset_password}, recipient_list=[user.email], ) messages.success( self.request, _("An email was sent with more details on how to create a new password" )) # Redirect to success_url return super(ResetPasswordView, self).form_valid(form)
def save(self): user = User.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.email) reset = PasswordReset(key=key, user=user) reset.save() template_name = 'account/password_reset_mail.html' subject = 'Criar nova senha de acesso para o Active Gears' context = {'reset': reset} send_mail_template(subject, template_name, context, [user.email])
def save(self): user = User.objects.get(email=self.cleaned_data["email"]) key = generate_hash_key(user.username) reset = PasswordReset(user=user, key=key) reset.save() template_name = "accounts/password_reset_mail.html" subject = "Criar nova senha no Simple MOOC" context = {"reset": reset} send_mail_template(subject, template_name, context, [user.email])
def save(self): user = AcoountUser.objects.get(email=form.cleaned_data['email']) key = generate_hash_key(user.username) reset = PasswordReset(key=key, user=user) reset.save() template_name = 'password_reset_mail.html' subject = 'Criar nova senha no Simple MOOC' context = {'reset': reset} send_mail_template(subject, template_name, context, [user.email])
def save(self): user = Person.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.name) reset = PasswordReset(user=user, key=key) reset.save() template_name = 'accounts/password_reset_email.html' subject = 'Recuperação de senha - Autoescola Esperança' context = {'reset': reset} send_mail_template(subject, template_name, context, [user.email])
def save(self): user = Usuario.objects.get(email=self.cleaned_data['username']) key = generate_hash_key(user.username) reset = NovaSenha(key=key, user=user) reset.save() base_url = self.scheme + "://" + self.get_host() template_name = 'accounts/reset_senha_mail.html' subject = 'Criar nova Senha no Defesas Ufba' context = {'reset': reset, 'base_url': base_url} send_mail_template(subject, template_name, context, [user.username])
def save(self): context = {} user = User.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.username) reset = PasswordReset(key=key, user=user) reset.save() # Enviar Email template_email = 'accounts/password_reset_mail.html' subject = 'Recuperar Senha na GReAT' context['reset'] = reset send_mail_template(subject, template_email, context, [user.email])
def save(self): user = User.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.username) reset = SenhaReset(key=key, user=user) reset.save() template_name = 'conta/password_reset_mail.html' subject = 'Criar nova senha no MammonTrading' context = { 'reset': reset, } send_mail_template(subject, template_name, context, [user.email])
def save(self): user = User.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.username) reset = PasswordReset(key=key, user=user) reset.save() template_name = 'accounts/password_reset_mail.html' subject = 'Criar nova senha no Simple MOOC' context = { 'reset': reset, } send_mail_template(subject, template_name, context, [user.email])
def save(self): user = User.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.username) reset = PasswordReset(key=key, user=user) reset.save() template_name = 'password_reset_mail.html' subject = 'TâmerMOOC - Resete sua senha' context = { 'reset': reset, } send_mail_template(subject, template_name, context, [user.email])
def save(self): user = User.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.username) reset = PasswordReset(key=key, user=user) reset.save() template_name = 'accounts/password_reset_mail.html' subject = 'Create new password on DevXpand' context = { 'reset': reset, } send_mail_template(subject, template_name, context, [user.email])
def save(self): user = User.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.username) redefinir = RedefinirSenha(key=key, nome=user) redefinir.save() template_name = 'accounts/redefinir_senha_email.html' context = { 'redefinir': redefinir #o que será passado como parametro } subject = 'Criar nova senha no simplemooc' send_mail_template(subject, template_name, context, [user.email])
def password_reset(request): template_name = 'usuarios/password_reset.html' context = {} form = PasswordResetForm(request.POST or None) if form.is_valid(): form.save() return redirect('usuarios:password_reset_confirm') context['form'] = form context['key'] = generate_hash_key(request.user.username) # adicionas esta linha para adicionar ao context return render(request, template_name, context)
def save(self): user = User.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.username) reset = PasswordReset(key=key, user=user) reset.save() template_name = 'accounts/password_reset_mail.html' subject = 'Criar nova senha ProxyManagerWeb' context = { 'reset': reset, } mail.send_mail_template(subject, template_name, context, [user.email])
def save(self): user = User.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.username) reset = PasswordReset(key=key, user=user) reset.save() context = { 'reset': reset, } envia_email_template('Nova Senha', 'mail_password_reset.html', context, [user.email])
def save(self): user = User.objects.get(email=self.cleaned_data['email']) key = generate_hash_key(user.username) reset = PasswordReset(key=key, user=user) reset.save() subject = 'Criar nova senha no Simple MOOC' to = [user.email] from_email = '*****@*****.**' context = { 'reset': reset, } message = render_to_string('acounts/password_reset_mail.html', context) msg = EmailMessage(subject, message, to=to, from_email=from_email) msg.content_subtype = 'html' msg.send()
def reset_senha(request): form = ResetSenhaForm(request.POST or None) context = {} if form.is_valid(): user = Usuario.objects.get(username=form.cleaned_data['username']) key = generate_hash_key(user.username) reset = NovaSenha(key=key, user=user) reset.save() base_url = request.scheme + "://" + request.get_host() template_name = 'accounts/reset_senha_mail.html' subject = 'Criar nova Senha no Defesas Ufba' context = {'reset': reset, 'base_url': base_url} send_mail_template(subject, template_name, context, [user.username]) context['success'] = True return redirect('accounts:login') template_name = 'accounts/reset_senha.html' context['form'] = form return render(request, template_name, context)
def gerar_token(request, pk): robo_comprado = get_object_or_404(RoboComprado, pk=pk, user=request.user) robo_comprado.token = generate_hash_key(robo_comprado.pk) robo_comprado.save() return redirect('conta:robos')