How to use set_activation_key method in Kiwi

Best Python code snippet using Kiwi_python

Controller.py

Source:Controller.py Github

copy

Full Screen

...72 users = self.__guard.get_resource(handle = 'users', type = Group)73 user = User(name, handle)74 user.set_password(password1)75 user.set_inactive()76 user.set_activation_key(key)77 self.__guard.add_resource(users, user)78 # Format activation email.79 #FIXME: Make configurable.80 domain = 'http://' + os.environ['HTTP_HOST']81 vars = self.__api.get_requested_uri(confirm = [1], key = [key])82 url = domain + vars83 filename = os.path.join(os.path.dirname(__file__), 'confirmation.txt')84 file = open(filename)85 mail_text = file.read().replace('$url', url).replace('$email', email)86 file.close()87 # Send email.88 server = smtplib.SMTP(self.server)89 #server.set_debuglevel(1)90 server.sendmail(self.mail_from, email, mail_text)91 server.quit()92 self.__api.render('mail_sent.tmpl', email = email)93 return True94 def confirm(self):95 # Find the user from the key.96 key = self.__api.get_data().get_str('key')97 attribs = {'activation_key': key}98 user = self.__guard.get_resource(attribute = attribs)99 if user is None:100 self.__api.render('register.tmpl', error = 'Invalid key')101 return102 # Activate the account.103 user.set_inactive(False)104 user.set_activation_key(None)105 self.__guard.save_resource(user)106 self.__api.render('complete.tmpl', user = user)107 def index(self, **kwargs):108 # If the user is already logged in do nothing.109 user = self.api.get_current_user()110 if user is not None:111 self.__api.render('complete.tmpl', user = user)112 return113 # If the link in the confirmation email was clicked, try114 # to activate the account.115 if self.__api.get_data().get_bool('confirm'):116 self.confirm()117 return118 # If the registration form was submitted, attempt to create...

Full Screen

Full Screen

forms.py

Source:forms.py Github

copy

Full Screen

...27 if commit:28 user.save()29 # initiate_user_with_default_setups(user)30 return user31 def set_activation_key(self):...

Full Screen

Full Screen

activation_key.py

Source:activation_key.py Github

copy

Full Screen

...9 resp = api._retrieve_activation()10 status = resp['status'].lower()11 if status in ('activated',):12 return b64encode(resp['activationCode'])13def set_activation_key(api, key_):14 activation = api._retrieve_activation()15 activation['activationCode'] = b64decode(key_)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kiwi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful