Exemplo n.º 1
0
 def create(self):
     """Create either a new admin or manager user in both the Manager table and Authkit Users table.
     """
     propertyFilter = request.POST['propertyId'] != 'false' and request.POST['propertyId'] or None 
     created_by = request.POST['created_by']
     manager_id = str(uuid.uuid1())
     company_id = request.environ.get("COMPANY_ID")
     first_name = request.POST['fname'].strip()
     last_name = request.POST['lname'].strip()
     email = request.POST['email'].strip()
     phone = request.POST['phone'].strip()
     usertype = int(request.POST['admin']) and 'admin' or 'manager'
     activation_code = str(uuid.uuid1())
     activation_link = 'http://{0}/activate/{1}'.format(settings.WEBSITE,activation_code)
     
     errorslist = self.validate(action='create')
     
     if errorslist:
         userJSON = {
             'errors': errorslist
         }
         return json.dumps(userJSON)
     
     model.Manager.create(
                          id = manager_id, 
                          companyid = company_id, 
                          first_name = first_name, 
                          last_name = last_name, 
                          email = email, 
                          phone = phone,
                          type = usertype,
                          activation_code = activation_code,
                          created_by = created_by
                          )
     
     
     meta.Session.commit()
     session.save()
     
     mailman.sendActivationLink(manager_id)
         
     return json.dumps({'currentUserId': manager_id})
Exemplo n.º 2
0
 def resendActivationLink(self):
     userId = request.POST['userId']
     errors = mailman.sendActivationLink(userId)
     return json.dumps({'errors':errors})