示例#1
0
    def register(self, password,email):
        session = EVCstate(trust=True)


        charname = None
        if 'Eve-Charname' in dict(cherrypy.request.headers):
            charname = cherrypy.request.headers['Eve-Charname']

        if charname is None:
            return evec_func.simple_error("No username found?")

        if password == "":
            return evec_func.simple_error("Please specify a password")


        if '@' not in email:
            return evec_func.simple_error("Please specify a semi-valid email address")


        db = evec_func.db_con()
        password = password.strip()
        r = User.register(db, password,email)
        if r is False:
            db.close()
            return evec_func.simple_error("Error: Registration error. You may already be registered or the system messed up")



        User.login(db, session, charname, password)
        emit_redirect('/users/')
        return """<html><head><title>Hi</title></head><body>
示例#2
0
    def login(self, username, password):
        session = EVCstate(trust=True)
        db = evec_func.db_con()

        res = None

        r = User.login(db, session, username, password)
        if r is not False:

            if 'isigb' not in session or not session['isigb']:
                emit_redirect('/users/index.html')


            res = "<html><head><title>Logged in</title></head><body>"
            res += "Logged in! Go to <a href=/users/index.html>user home</a>. You are getting this page because the IGB does not know how to redirect."
            res += "</body></html>"
            session['user'] = r


        else:

            res = "<html><head><title>Login failed</title></head><body>"
            res += "Your login failed due to a bad password or username."
            res += "<form method=GET action=/users/passreset.html>Send a reset email for the user " + username
            res += " to the email address <input type=text name=uemail> (must match email on file!)"
            res += "<input type=hidden name=username value=\""+username+"\"><input type=submit value=Send>"
            res += "</form>"
            res += "</body></html>"



        db.close()
        return res