Exemplo n.º 1
0
 def post(self):
     a = self.get_argument("a","")
     uname = self.get_argument("uname","")
     urole = self.get_argument("urole","developer")
     upwd1 = self.get_argument("upassword","")
     upwd2 = self.get_argument("upassword2","")
     picname = self.get_argument("upicname",config.DEFAULT_HEAD)
     uavatar = list(self.request.files.items())
     udscpt = self.get_argument("udescription","")
     if not (self.accessSelf(uname) or self.accessAdmin()):
         ##不是自己操作或者不是管理员则返回
         self.permissionDenied()
         return
     if (a =='add'):
         if (not (upwd1 == upwd2)) or (upwd1==""):
             self.write("密码输入不一致")
             return
         mtime = int(time.time())
         if (len(uavatar)>0):
             (field, mpic) = uavatar[0]
             for picfile in mpic:
                 picname ="/static/images/"+ (picfile["filename"])
                 #1, 保存新应用的图标
                 utils.saveBin("."+picname, picfile["body"])
         # 确保只有管理员可以改变用户角色
         if not self.accessAdmin():
             urole = "developer"
         #3, 保存在数据库里
         self.logI(u"保存开发者信息:%s:%s"%(uname,urole))
         model.add_new_user(uname, utils.sha256(upwd1), urole, picname, udscpt, mtime)
     self.seeother("/publish")
Exemplo n.º 2
0
def create_account():
    model.connect_to_db()
    username = request.form.get('username')
    password = request.form.get('password')
    if model.get_user_by_name(username):
        flash("That user already exists!")
        return redirect(url_for("register"))
    else:
        model.add_new_user(username, password)
        flash("New user created!")
        return redirect(url_for("index"))
Exemplo n.º 3
0
def create_account():
    model.connect_to_db()
    username = request.form.get('username')
    password = request.form.get('password')    
    if model.get_user_by_name(username):
        flash("That user already exists!")
        return redirect(url_for("register"))
    else:
        model.add_new_user(username, password)
        flash("New user created!")
        return redirect(url_for("index"))
Exemplo n.º 4
0
def create_account():
    if session.get('username'):
        redirect(url_for("view_user", username = session.get("username")))
    else:
        model.connect_to_db()
        username = request.form.get("username")
        user_id = model.new_user_id()
        if request.form.get("password") == request.form.get("password_verify"):
            password = request.form.get("password")
        if model.get_user_by_name(username):
            flash("That username is already taken!")
            return redirect(url_for("register"))
        else:
            model.add_new_user(user_id, username, password)
        return redirect(url_for("view_user", username=username))
Exemplo n.º 5
0
def add_user():
    model.connect_to_db()
    email = request.args.get("email")
    password = request.args.get("password")
    user = model.add_new_user(email, password)
    return "Successfully added a user!"
Exemplo n.º 6
0
def add_userid_db_session(userid):
    """Take userid and add user to User table and session."""
    model.add_new_user(userid)

    session['user_spot_id'] = userid
    flash("Logged in.")