def delete(self, shop_id): is_authenticated(request, self.public_key, self.auth_host, self.auth_algo, role='admin') return self.delete_shop(shop_id), 204
def get(self): is_authenticated(request, public_key=self.public_key, auth_host=self.auth_host, auth_algo=self.auth_algo, role='admin') users = self.database['users'] result=[] for user in users.find({},{"password":0}): user["_id"] = json.loads(json_util.dumps(user["_id"]))["$oid"] result.append(user) return result
def put(self, shop_id): is_authenticated(request, self.public_key, self.auth_host, self.auth_algo, role='admin') args = self.shop_parser.parse_args() if not (args["name"] and args["address"] and args["longitude"] and args["latitude"]): abort(400, message='missing arguments') return self.update_shop(shop_id, args["name"], args["address"], args["longitude"], args["latitude"]), 201
def delete(self): user = is_authenticated(request, self.public_key, self.auth_host, self.auth_algo) args = self.shop_parser.parse_args() return self.unlik_undislike_shop(args["_id"], user["login"], undislike=True), 204
def post(self): user = is_authenticated(request, self.public_key, self.auth_host, self.auth_algo) args = self.shop_parser.parse_args() return self.like_dislike_shop(user["login"], args["_id"], dislike=True), 201
def get(self): user = is_authenticated(request, self.public_key, self.auth_host, self.auth_algo) args = self.location_parser.parse_args() return self.find_shops(disliked=True, user_login=user['login'], longitude=args['longitude'], latitude=args['latitude'])
def delete(self): is_authenticated(request, self.public_key, self.auth_host, self.auth_algo, role='admin') args = self.user_parser.parse_args() users = self.database['users'] old_user = self.user_exists(args["login"]) if not old_user: abort(400, message="User doesn't exist") else: user_id = ObjectId(old_user["_id"]) users.delete_one({"_id": user_id}) if not self.user_exists(args["login"]): return '', 204 else: abort(400, message="Delete failed")
def put(self): args = self.user_parser.parse_args() user = is_authenticated(request, self.public_key, self.auth_host, self.auth_algo) if not isValidEmail(args["login"]): abort(400, message='Invalid Email Address') login = args['login'] password = args['password'] if user["login"] == login or user["role"] == "admin": old_user = self.user_exists(login) if not old_user: abort(400, message="User doesn't exists") users = self.database["users"] user['_id'] = ObjectId(old_user["_id"]) status = users.replace_one({"login": user["login"]}, user) if status.matched_count == 1 and status.modified_count == 1: del user["password"] return user, 201 else: abort(400, message="Update failed")
def delete(self): user = is_authenticated(request, self.public_key, self.auth_host, self.auth_algo) args = self.shop_parser.parse_args() if not args["_id"]: abort(400, message='missing arguments') return self.unlik_undislike_shop(shop_id=args["_id"],user_login=user["login"]), 204
def get(self, shop_id): is_authenticated(request, self.public_key, self.auth_host, self.auth_algo) return self.find_shops(shop_id=shop_id)
id_storage = anydbm.open('/tmp/oyster_sessionids', 'c') id_storage[hashed_id] = str(datetime.datetime.now()) id_storage.close() print cookie just_authenticated = True else: password_failed = True common.navigation_header(title="Admin Login") if not os.path.exists(config['basedir']): print "<p>Please start Oyster before trying to login.</p>" common.html_footer() sys.exit() if password_failed: print "<p>Password incorrect.</p>" elif just_authenticated or common.is_authenticated(): print "<p>Authenticated! Please visit the <a class='file' href='home.py'>main page</a> now.</p>" common.html_footer() sys.exit() print """ <form method='post' action='admin.py' " + "enctype='application/x-www-form-urlencoded'> <input type="password" name="password"/> <input type="submit" value="Login"/> </form> """ common.html_footer()