Exemple #1
0
 def _post(self):
     username = self.request.get("username")
     email = self.request.get("email")
     model = UserModel(verified=False)
     model.assign(self)
     if model.validate():
         if config.get_config("user_email_confirm") == "yes":
             model.put()
             user_confirm.send_confirmation_mail(username, email)
             values = {
                     "message": _(u"""An email that contains the link to activate the account \
                         has been sent to the email"""),
                     "redirect": None,
                     }
             return self.render("noticepage", values)
         else:
             model.verified = True
             user_key = model.put()
             rbac.add_role(user_key, rbac.default_role("registered"))
             values = {
                     "message": _(u"""Successfully registered."""),
                     "redirect": None,
                     }
             return self.render("noticepage", values)
     else:
         values = {
                 "model": model
                 }
         return self.render("admin_user_add", values)
Exemple #2
0
def perform_installation(*args, **kwds):
    # Set up Role-based Access Control
    install_rbac()

    q = UserModel.query(UserModel.username == "admin").get()
    if not q:
        model = UserModel(
            username="******", display_name=_("Admin"), password="******", email="*****@*****.**", verified=True
        )
        model.put(force_validation=False)
        rbac.add_role(model.key, rbac.default_role("super_admin"))

    # Configurations
    for item in config_setup.default_configs():
        config.update_config(item.name, item.value, item.visible)
Exemple #3
0
def perform_installation(*args, **kwds):
    #Set up Role-based Access Control
    install_rbac();

    q = UserModel.query(UserModel.username=="admin").get()
    if not q:
        model = UserModel(username="******", password="******", email="*****@*****.**", verified=True)
        model.put(force_validation=False)
        rbac.add_role(model.key, rbac.default_role("super_admin"))

    #Configurations
    conf = [
            ("site_name", "Name", True),
            ("session_secret_key", utils.generate_random_string(30), False),
            ("admin_email", "*****@*****.**", True),
            ("user_email_confirm", "no", True),
        ]
    for item in conf:
        config.update_config(item[0], item[1], item[2])
Exemple #4
0
 def get(self):
     username = self.request.get("user")
     token = self.request.get("token")
     q = ndb.gql("SELECT token FROM UserConfirmationModel WHERE username = :1", username).get()
     if (not q) or (q.token != token):
         values = {
             "message": _("Your confirmation link is invalid, sorry but please check your mail box again."),
             "redirect": None,
         }
         return self.render("noticepage", values)
     else:
         q.delete()
         the_user = UserModel.query(UserModel.username == username).get()
         the_user.verified = True
         user_key = the_user.put()
         rbac.add_role(user_key, rbac.default_role("registered"))
         values = {
             "message": _(
                 "Congratulations! Your account has been successfully activated \
                                 , thanks for registering."
             ),
             "redirect": self.uri_for("home"),
         }
         return self.render("noticepage", values)