Example #1
0
    def me(self):
        if (request.method == "GET"):
            cookie = request.cookies.get("GFB_Cookie")
            if (cookie == None):
                return ''
            else:
                decode = Cookie.decryptCookie(cookie)
                return json.dumps(decode)
        else:  #open host site
            cookie = request.cookies.get("GFB_Cookie")
            if (cookie == None):
                return ''
            else:
                encode = {}
                decode = Cookie.decryptCookie(cookie)
                encode['role'] = decode['role']
                encode['user_name'] = decode['user_name']
                encode['email'] = decode['email']

                if (request.params['changed'] == 'true'):
                    encode['host_site'] = request.params['siteID']
                else:
                    encode['host_site'] = ''

                cookie = Cookie(encode['user_name'], encode['email'],
                                encode['role'], encode['host_site'])
                response.delete_cookie('GFB_Cookie')
                response.set_cookie("GFB_Cookie",
                                    cookie.encryptCookie(),
                                    max_age=180 * 24 * 3600)

                return render('/tools/distOrders.mako')
Example #2
0
    def auth(self):
        db = DB()
        if (request.method == "GET"):
            # Check if user's email and password are matched
            success = db.authUser(request.params['email'],
                                  request.params['password'])

            if (success):
                # Setup the cookie (encrypted) with useful information
                user = db.getUser(request.params['email'])
                cookie = Cookie(user.get('first_name'), user.get('email'),
                                user.get('fk_credentials'),
                                user.get('fk_hostsite_id'))
                response.set_cookie("GFB_Cookie",
                                    cookie.encryptCookie(),
                                    max_age=180 * 24 * 3600)
                return self.trueString
            else:
                return "{\"success\" : \"false\", \"message\" : \"Unable to login: bad username or password\"}"
        else:
            return "{\"success\" : \"false\", \"message\" : \"Bad request.\"}"
Example #3
0
    def auth(self):
        db = DB()
        if (request.method == "GET"):
            # authenticate with the database controller, assume that login is setting request params with username and password
            # I want the role
            # success = authUser(email, password)
            success = True

            if (success):
                # role, username, password
                # user = db.getUser()
                # cookie = Cookie(email, password, user.get('role'))

                cookie = Cookie('miakilborn', 'thisismypassword!', '1')
                response.set_cookie("FCS_GFB_Cookie",
                                    cookie.encryptCookie(),
                                    max_age=180 * 24 * 3600)
                return true_string
            else:
                return "{\"success\" : \"false\", \"message\" : \"Unable to login: bad username or password\"}"
        else:
            return "{\"success\" : \"false\", \"message\" : \"\"}"