Added more to navbar.
This commit is contained in:
parent
a5298ecff9
commit
a6566d3fce
4 changed files with 35 additions and 24 deletions
|
@ -27,8 +27,8 @@ server {
|
||||||
try_files /index.html /index.html;
|
try_files /index.html /index.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ /static {
|
location /static {
|
||||||
root /srv/http/static;
|
alias /srv/http/static;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ /api {
|
location ~ /api {
|
||||||
|
|
|
@ -132,6 +132,8 @@ def user_status():
|
||||||
"success": 1,
|
"success": 1,
|
||||||
"logged_in": logged_in,
|
"logged_in": logged_in,
|
||||||
"admin": is_admin(),
|
"admin": is_admin(),
|
||||||
|
"competition": is_admin(),
|
||||||
|
"in_team": in_team(get_user()),
|
||||||
"username": session["username"] if logged_in else "",
|
"username": session["username"] if logged_in else "",
|
||||||
}
|
}
|
||||||
if logged_in:
|
if logged_in:
|
||||||
|
@ -260,24 +262,6 @@ UserSchema = Schema({
|
||||||
"notify": str
|
"notify": str
|
||||||
}, extra=True)
|
}, extra=True)
|
||||||
|
|
||||||
def get_user(username=None, username_lower=None, email=None, uid=None, reset_token=None):
|
|
||||||
match = {}
|
|
||||||
if username != None:
|
|
||||||
match.update({ "username": username })
|
|
||||||
elif username_lower != None:
|
|
||||||
match.update({ "username_lower": username_lower })
|
|
||||||
elif uid != None:
|
|
||||||
match.update({ "uid": uid })
|
|
||||||
elif email != None:
|
|
||||||
match.update({ "email": email })
|
|
||||||
elif is_logged_in():
|
|
||||||
match.update({ "username": session["username"] })
|
|
||||||
elif reset_token != None:
|
|
||||||
match.update({ "reset_token": reset_token })
|
|
||||||
with app.app_context():
|
|
||||||
result = Users.query.filter_by(**match)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def login_user(username, password):
|
def login_user(username, password):
|
||||||
user = get_user(username_lower=username.lower()).first()
|
user = get_user(username_lower=username.lower()).first()
|
||||||
if user is None: return False
|
if user is None: return False
|
||||||
|
@ -303,9 +287,6 @@ def login_user(username, password):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def in_team(user):
|
|
||||||
return user.tid is not None and user.tid >= 0
|
|
||||||
|
|
||||||
def is_logged_in():
|
def is_logged_in():
|
||||||
if not("sid" in session and "username" in session): return False
|
if not("sid" in session and "username" in session): return False
|
||||||
sid = session["sid"]
|
sid = session["sid"]
|
||||||
|
@ -320,9 +301,30 @@ def is_logged_in():
|
||||||
if token.ua != useragent: return False
|
if token.ua != useragent: return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def get_user(username=None, username_lower=None, email=None, uid=None, reset_token=None):
|
||||||
|
match = {}
|
||||||
|
if username != None:
|
||||||
|
match.update({ "username": username })
|
||||||
|
elif username_lower != None:
|
||||||
|
match.update({ "username_lower": username_lower })
|
||||||
|
elif uid != None:
|
||||||
|
match.update({ "uid": uid })
|
||||||
|
elif email != None:
|
||||||
|
match.update({ "email": email })
|
||||||
|
elif is_logged_in():
|
||||||
|
match.update({ "username": session["username"] })
|
||||||
|
elif reset_token != None:
|
||||||
|
match.update({ "reset_token": reset_token })
|
||||||
|
with app.app_context():
|
||||||
|
result = Users.query.filter_by(**match)
|
||||||
|
return result
|
||||||
|
|
||||||
def is_admin():
|
def is_admin():
|
||||||
return is_logged_in() and "admin" in session and session["admin"]
|
return is_logged_in() and "admin" in session and session["admin"]
|
||||||
|
|
||||||
|
def in_team(user):
|
||||||
|
return hasattr(user, "tid") and user.tid >= 0
|
||||||
|
|
||||||
def validate_captcha(form):
|
def validate_captcha(form):
|
||||||
if "captcha_response" not in form:
|
if "captcha_response" not in form:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -53,6 +53,15 @@
|
||||||
<div ng-show="config.navbar['competition_started']==true">
|
<div ng-show="config.navbar['competition_started']==true">
|
||||||
</div>
|
</div>
|
||||||
<li><a href="/chat">Chat</a></li>
|
<li><a href="/chat">Chat</a></li>
|
||||||
|
<li class="dropdown" ng-show="config.navbar['competition']==true">
|
||||||
|
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Competition <span class="caret"></span></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href="/problems">Problems</a></li>
|
||||||
|
<li><a href="/programming">Programming</a></li>
|
||||||
|
<li><a href="/shell">Shell</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li ng-show="config.navbar['competition']!=true&&config.navbar['in_team']!=true"><a href="/findteam">Find Team</a></li>
|
||||||
<li class="dropdown" ng-show="config.navbar['admin']==true">
|
<li class="dropdown" ng-show="config.navbar['admin']==true">
|
||||||
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Admin <span class="caret"></span></a>
|
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Admin <span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
<h1>404: Page Not Found</h1>
|
<h1>404: Page Not Found</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>Go away. Stop snooping around, you little creep.</p>
|
<p>Ok, ok, here's your flag: <code>bm8gZWFzdGVyIGVnZyBoZXJl</code>.</p>
|
Loading…
Add table
Reference in a new issue