Skip to content

Commit e9a3ee0

Browse files
committed
add : auth added.
1 parent 447380b commit e9a3ee0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

mafia.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
from sys import argv
22
from random import randrange, shuffle
33
from flask import Flask, render_template, url_for, request
4+
from flask_httpauth import HTTPBasicAuth
45
from mafia_params import *
56

67
app = Flask(__name__)
8+
auth = HTTPBasicAuth()
79
id = 0
810
nPlayers = 0
911
roles = []
1012
ip2role_idx = {}
1113

14+
@auth.verify_password
15+
def verify_password(username, password):
16+
if len(username) > 0:
17+
return username
18+
return None
19+
1220
@app.route('/')
21+
@auth.login_required
1322
def index():
1423
global id, ip2role_idx
1524
role = ""

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22

33
# mafia/mafia.py: 3
44
Flask == 1.1.2
5+
6+
# mafia/mafia.py: 4
7+
Flask_HTTPAuth == 4.1.0

0 commit comments

Comments
 (0)