def post(self,*args,**kargs): username = self.request.get('username') user = self.user_model.get_by_auth_id(username) if not user: logging.info('Could not find any user entry for username %s', username) self.response.write("not found") return user_id = user.get_id() token = self.user_model.create_signup_token(user_id) verification_url = self.uri_for('verification', type='p', user_id=user_id, signup_token=token, _full=True) msg = """Hi """+username+""", Follow the link to reset your password You will be able to do so by visiting {url}""" message = mail.EmailMessage(sender=OUT_MAIL_ADDRESS, subject="Reset Password") message.to = username message.body = msg.format(url=verification_url) message.send() # self.response.write("true") domain=str(self.user_model.get_by_id(user_id).tenant_domain) new_url=self.uri_for('login',_netloc=str(domain+"."+urlparse.urlparse(self.request.url).netloc)) # self.redirect(self.uri_for('login',_netloc=str(domain+"."+urlparse.urlparse(self.request.url).netloc))) self.response.write(new_url)
def post(self,*args,**kargs): #role=model.user.Groups() role=ndb.Key(urlsafe=self.request.get('role')) user_name = self.request.get('email') email = self.request.get('email') name = self.request.get('first_name') last_name = self.request.get('last_name') designation = self.request.get('designation') empid=self.request.get('emp_id') contact=self.request.get('contact_no') password = name+empid #unique_properties = ['email_address'] user_data = self.user_model.create_user(user_name, email_address=email, name=name, password_raw=password,designation=designation,empid=empid,contact=contact, last_name=last_name,role=role,verified=False) if not user_data[0]: #user_data is a tuple self.response.write('User already exists with the same name') return user = user_data[1] user_id = user.get_id() token = self.user_model.create_signup_token(user_id) verification_url = self.uri_for('verification', type='v', user_id=user_id,signup_token=token, _full=True) msg = """Hi """+name+""", Thank you for registering on APM. Please follow the below url to activate your account. Remember to change your password. You will be able to do so by visiting {url}""" message = mail.EmailMessage(sender=OUT_MAIL_ADDRESS, subject="Account Verification") message.to = email message.body = msg.format(url=verification_url) message.send() logging.info(msg.format(url=verification_url)) self.response.write("true")
def post(self,*args,**kargs): #role=model.user.Groups() tenant_domain = self.request.get('company_domain') tenant_name = self.request.get('company_name') tenant = model.user.Tenant() tenant.name = tenant_name tenant.domain = tenant_domain tenant.created_by = self.request.get('email') duplicate_tenant = tenant.query(model.user.Tenant.domain==tenant_domain).fetch() if duplicate_tenant: self.response.write('Domain already exists with the same name.') return else: tenant_key_added = tenant.put() role=ndb.Key(urlsafe=self.request.get('role')) user_name = self.request.get('email') email = self.request.get('email') name = self.request.get('company_name') last_name = self.request.get('company_name') designation = "" empid="" contact="" tenant_key = tenant_key_added password = name+empid #unique_properties = ['email_address'] user_data = self.user_model.create_user(user_name, email_address=email, name=name, password_raw=password,designation=designation,empid=empid,contact=contact, last_name=last_name,role=role,tenant_domain=tenant_domain,status = True,tenant_key=tenant_key,project_permission=True,verified=False) if not user_data[0]: #user_data is a tuple self.response.write('User already exists with the same email.') return user = user_data[1] user_id = user.get_id() token = self.user_model.create_signup_token(user_id) verification_url = self.uri_for('verification', type='v', user_id=user_id,signup_token=token, _full=True) logging.info("before email"); message= """Hi """+name+""", Thank you for registering on APM. Please follow the below url to activate your account. Remember to change your password. You will be able to do so by visiting {url}""" task = taskqueue.add( queue_name = "my-push-queue", url='/email', params={'To_email':email,'verification_url':verification_url,'message':message}) logging.info("after email") logging.info(verification_url) self.response.write('true')
def post(self, *args, **kargs): currentUser = self.auth.get_user_by_session() user_name = self.request.get('email') email = self.request.get('email') name = self.request.get('first_name') role = ndb.Key(urlsafe=self.request.get('role')) last_name = self.request.get('last_name') designation = self.request.get('designation') empid = self.request.get('emp_id') contact = self.request.get('contact_no') password = name + empid company_domain = self.user_model.get_by_id( currentUser['user_id']).tenant_domain company_key = self.user_model.get_by_id( currentUser['user_id']).tenant_key #unique_properties = ['email_address'] user_data = self.user_model.create_user(user_name, email_address=email, name=name, password_raw=password, designation=designation, empid=empid, contact=contact, last_name=last_name, role=role, tenant_key=company_key, tenant_domain=company_domain, verified=False) if not user_data[0]: #user_data is a tuple self.response.write('User already exists with the same name') return user = user_data[1] user_id = user.get_id() token = self.user_model.create_signup_token(user_id) verification_url = self.uri_for('verification', type='v', user_id=user_id, signup_token=token, _full=True) msg = """Hi """ + name + """, Thank you for registering on APM. Please follow the below url to activate your account. Remeber to change your password. You will be able to do so by visiting {url}""" message = mail.EmailMessage(sender=OUT_MAIL_ADDRESS, subject="Account Verification") message.to = email message.body = msg.format(url=verification_url) message.send() logging.info(verification_url) self.response.write("true")
def post(self): #role=model.user.Groups() tenant_domain = self.request.get('company_domain') tenant_name = self.request.get('company_name') tenant = model.user.Tenant() tenant.name = tenant_name tenant.domain = tenant_domain tenant.created_by = self.request.get('email') if tenant.query(model.user.Tenant.domain==tenant_domain).fetch(): self.response.write('Domain already exists with the same name.') return else: tenant_key_added = tenant.put() logging.info(tenant_key_added) role=ndb.Key(urlsafe=self.request.get('role')) user_name = self.request.get('email') email = self.request.get('email') name = self.request.get('first_name') last_name = self.request.get('last_name') designation = self.request.get('designation') empid=self.request.get('emp_id') contact=self.request.get('contact_no') tenant_key = tenant_key_added password = name+empid user_info = self.auth.get_user_by_session() created_by = user_info['email_address'] status = True #unique_properties = ['email_address'] user_data = self.user_model.create_user(user_name, email_address=email, name=name, password_raw=password,designation=designation,empid=empid,contact=contact, last_name=last_name,role=role,tenant_domain=tenant_domain,tenant_key=tenant_key,created_by=created_by,status=status, verified=False) if not user_data[0]: #user_data is a tuple self.response.write('User already exists with the same email.') return user = user_data[1] user_id = user.get_id() token = self.user_model.create_signup_token(user_id) verification_url = self.uri_for('verification', type='v', user_id=user_id,signup_token=token, _full=True) msg = """Hi """+name+""", Thank you for registering on APM. Please follow the below url to activate your account. Remeber to change your password. You will be able to do so by visiting {url}""" message = mail.EmailMessage(sender=OUT_MAIL_ADDRESS, subject="Account Verification") message.to = email message.body = msg.format(url=verification_url) message.send() logging.info(msg.format(url=verification_url)) self.response.write("true")
def post(self,*args,**kargs): password = self.request.get('password') old_token = self.request.get('t') if not password or password != self.request.get('confirm_password'): self.response.write('nomatch') return user = self.user user.set_password(password) user.put() # remove signup token, we don't want users to come back with an old link self.user_model.delete_signup_token(user.get_id(), old_token) domain=str(user.tenant_domain) self.redirect(self.uri_for('subdomain-home',_netloc=str(domain+"."+urlparse.urlparse(self.request.url).netloc)))
def post(self, *args, **kargs): password = self.request.get('password') old_token = self.request.get('t') if not password or password != self.request.get('confirm_password'): self.response.write('nomatch') return user = self.user user.set_password(password) user.put() # remove signup token, we don't want users to come back with an old link self.user_model.delete_signup_token(user.get_id(), old_token) domain = str(user.tenant_domain) self.redirect( self.uri_for( 'subdomain-home', _netloc=str(domain + "." + urlparse.urlparse(self.request.url).netloc)))
def get(self, *args, **kwargs): user = None user_id = kwargs['user_id'] signup_token = kwargs['signup_token'] verification_type = kwargs['type'] # it should be something more concise like # self.auth.get_user_by_token(user_id, signup_token) # unfortunately the auth interface does not (yet) allow to manipulate # signup tokens concisely user, ts = self.user_model.get_by_auth_token(int(user_id), signup_token, 'signup') if not user: logging.info( 'Could not find any user with id "%s" signup token "%s"', user_id, signup_token) self.abort(404) # store user data in the session self.auth.set_session(self.auth.store.user_to_dict(user), remember=True) if verification_type == 'v': # remove signup token, we don't want users to come back with an old link self.user_model.delete_signup_token(user.get_id(), signup_token) if not user.verified: user.verified = True user.put() self.render_template('auth/change-password.html') #return elif verification_type == 'p': # supply user to the page params = {'user': user, 'token': signup_token} self.render_template('auth/change-password.html', params) else: logging.info('verification type not supported') self.abort(404)
def post(self, *args, **kargs): username = self.request.get('username') user = self.user_model.get_by_auth_id(username) if not user: logging.info('Could not find any user entry for username %s', username) self.response.write("not found") return user_id = user.get_id() token = self.user_model.create_signup_token(user_id) verification_url = self.uri_for('verification', type='p', user_id=user_id, signup_token=token, _full=True) msg = """Hi """ + username + """, Follow the link to reset your password You will be able to do so by visiting {url}""" message = mail.EmailMessage(sender=OUT_MAIL_ADDRESS, subject="Reset Password") message.to = username message.body = msg.format(url=verification_url) message.send() # self.response.write("true") domain = str(self.user_model.get_by_id(user_id).tenant_domain) new_url = self.uri_for( 'login', _netloc=str(domain + "." + urlparse.urlparse(self.request.url).netloc)) # self.redirect(self.uri_for('login',_netloc=str(domain+"."+urlparse.urlparse(self.request.url).netloc))) self.response.write(new_url)
def get(self, *args, **kwargs): user = None user_id = kwargs['user_id'] signup_token = kwargs['signup_token'] verification_type = kwargs['type'] # it should be something more concise like # self.auth.get_user_by_token(user_id, signup_token) # unfortunately the auth interface does not (yet) allow to manipulate # signup tokens concisely user, ts= self.user_model.get_by_auth_token(int(user_id), signup_token,'signup') if not user: logging.info('Could not find any user with id "%s" signup token "%s"', user_id, signup_token) self.abort(404) # store user data in the session self.auth.set_session(self.auth.store.user_to_dict(user), remember=True) if verification_type == 'v': # remove signup token, we don't want users to come back with an old link self.user_model.delete_signup_token(user.get_id(), signup_token) if not user.verified: user.verified = True user.put() self.render_template('auth/change-password.html') #return elif verification_type == 'p': # supply user to the page params = { 'user': user, 'token': signup_token } self.render_template('auth/change-password.html', params) else: logging.info('verification type not supported') self.abort(404)
def post(self, *args, **kargs): #role=model.user.Groups() tenant_domain = self.request.get('company_domain') tenant_name = self.request.get('company_name') tenant = model.user.Tenant() tenant.name = tenant_name tenant.domain = tenant_domain tenant.created_by = self.request.get('email') duplicate_tenant = tenant.query( model.user.Tenant.domain == tenant_domain).fetch() if duplicate_tenant: self.response.write('Domain already exists with the same name.') return else: tenant_key_added = tenant.put() role = ndb.Key(urlsafe=self.request.get('role')) user_name = self.request.get('email') email = self.request.get('email') name = self.request.get('company_name') last_name = self.request.get('company_name') designation = "" empid = "" contact = "" tenant_key = tenant_key_added password = name + empid #unique_properties = ['email_address'] user_data = self.user_model.create_user(user_name, email_address=email, name=name, password_raw=password, designation=designation, empid=empid, contact=contact, last_name=last_name, role=role, tenant_domain=tenant_domain, status=True, tenant_key=tenant_key, project_permission=True, verified=False) if not user_data[0]: #user_data is a tuple self.response.write('User already exists with the same email.') return user = user_data[1] user_id = user.get_id() token = self.user_model.create_signup_token(user_id) verification_url = self.uri_for('verification', type='v', user_id=user_id, signup_token=token, _full=True) logging.info("before email") message = """Hi """ + name + """, Thank you for registering on APM. Please follow the below url to activate your account. Remember to change your password. You will be able to do so by visiting {url}""" task = taskqueue.add(queue_name="my-push-queue", url='/email', params={ 'To_email': email, 'verification_url': verification_url, 'message': message }) logging.info("after email") logging.info(verification_url) self.response.write('true')
def post(self,*args,**kargs): currentUser=self.auth.get_user_by_session() submit=self.request.get('add_user') logging.info('submit:'+submit) user_name = self.request.get('email') email = self.request.get('email') name = self.request.get('first_name') role= ndb.Key(urlsafe=self.request.get('role')) if(self.request.get('proj') == 'True'): project_permission = True else: project_permission = False logging.info(role) last_name = self.request.get('last_name') designation = self.request.get('designation') empid=self.request.get('emp_id') contact=self.request.get('contact_no') password = name+empid user_info = self.auth.get_user_by_session() created_by = user_info['email_address'] status = True company_domain=self.user_model.get_by_id(currentUser['user_id']).tenant_domain company_key=self.user_model.get_by_id(currentUser['user_id']).tenant_key #unique_properties = ['email_address'] user_data = self.user_model.create_user(user_name, email_address=email, name=name, password_raw=password,designation=designation,empid=empid,contact=contact, last_name=last_name,role=role,tenant_key=company_key,tenant_domain=company_domain,created_by=created_by,status=status,project_permission=project_permission,verified=False) if not user_data[0]: #user_data is a tuple self.response.write('User already exists with the same email') return user = user_data[1] user_id = user.get_id() token = self.user_model.create_signup_token(user_id) verification_url = self.uri_for('verification', type='v', user_id=user_id,signup_token=token, _full=True) verification_url ='http://'+APP_DOMAIN+urlparse(verification_url)[2] message = """Hi """+name.upper()+""", """+ user_info['name'].upper() +""" has registered you on APM . Please follow the below url to activate your account. Remember to change your password. You will be able to do so by visiting {url}""" task = taskqueue.add( queue_name = "my-push-queue", url='/email', params={'To_email':email,'verification_url':verification_url,'message':message}) logging.info("after email") # message = mail.EmailMessage(sender="*****@*****.**", # subject="Account Verification") # message.to = email # message.body = msg.format(url=verification_url) # message.send() # logging.info(msg.format(url=verification_url)) self.response.write("true")
def post(self): #role=model.user.Groups() tenant_domain = self.request.get('company_domain') tenant_name = self.request.get('company_name') tenant = model.user.Tenant() tenant.name = tenant_name tenant.domain = tenant_domain tenant.created_by = self.request.get('email') if tenant.query(model.user.Tenant.domain == tenant_domain).fetch(): self.response.write('Domain already exists with the same name.') return else: tenant_key_added = tenant.put() logging.info(tenant_key_added) role = ndb.Key(urlsafe=self.request.get('role')) user_name = self.request.get('email') email = self.request.get('email') name = self.request.get('first_name') last_name = self.request.get('last_name') designation = self.request.get('designation') empid = self.request.get('emp_id') contact = self.request.get('contact_no') tenant_key = tenant_key_added password = name + empid user_info = self.auth.get_user_by_session() created_by = user_info['email_address'] status = True #unique_properties = ['email_address'] user_data = self.user_model.create_user(user_name, email_address=email, name=name, password_raw=password, designation=designation, empid=empid, contact=contact, last_name=last_name, role=role, tenant_domain=tenant_domain, tenant_key=tenant_key, created_by=created_by, status=status, verified=False) if not user_data[0]: #user_data is a tuple self.response.write('User already exists with the same email.') return user = user_data[1] user_id = user.get_id() token = self.user_model.create_signup_token(user_id) verification_url = self.uri_for('verification', type='v', user_id=user_id, signup_token=token, _full=True) msg = """Hi """ + name + """, Thank you for registering on APM. Please follow the below url to activate your account. Remeber to change your password. You will be able to do so by visiting {url}""" message = mail.EmailMessage(sender=OUT_MAIL_ADDRESS, subject="Account Verification") message.to = email message.body = msg.format(url=verification_url) message.send() logging.info(msg.format(url=verification_url)) self.response.write("true")