webpage for token
+ fix
This commit is contained in:
		@@ -102,8 +102,7 @@ def requires_auth(f):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if auth_method == 'password':
 | 
					        if auth_method == 'password':
 | 
				
			||||||
            auth = request.authorization
 | 
					            auth = request.authorization
 | 
				
			||||||
            if var.config.getboolean("webinterface", "require_auth") and (
 | 
					            if not auth or not check_auth(auth.username, auth.password):
 | 
				
			||||||
                    not auth or not check_auth(auth.username, auth.password)):
 | 
					 | 
				
			||||||
                if auth:
 | 
					                if auth:
 | 
				
			||||||
                    log.info(f"web: failed login attempt, user: {auth.username}, from ip {request.remote_addr}.")
 | 
					                    log.info(f"web: failed login attempt, user: {auth.username}, from ip {request.remote_addr}.")
 | 
				
			||||||
                return authenticate()
 | 
					                return authenticate()
 | 
				
			||||||
@@ -127,8 +126,10 @@ def requires_auth(f):
 | 
				
			|||||||
                    session['user'] = token_user
 | 
					                    session['user'] = token_user
 | 
				
			||||||
                    return f(*args, **kwargs)
 | 
					                    return f(*args, **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            log.debug(f"web: bad token from ip {request.remote_addr}.")
 | 
					            log.info(f"web: bad token from ip {request.remote_addr}.")
 | 
				
			||||||
            abort(403)
 | 
					            return render_template('need_token.html',
 | 
				
			||||||
 | 
					                                   name=var.config.get('bot','username'),
 | 
				
			||||||
 | 
					                                   command=f"{var.config.get('commands', 'command_symbol')[0]}{var.config.get('commands','requests_webinterface_access')}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return f(*args, **kwargs)
 | 
					        return f(*args, **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										50
									
								
								templates/need_token.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								templates/need_token.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					<!DOCTYPE html>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<head>
 | 
				
			||||||
 | 
					    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
 | 
				
			||||||
 | 
					    <meta charset="UTF-8">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <title>botamusique web interface</title>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <link rel="icon" href="static/image/favicon.ico" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <link id="pagestyle" rel="stylesheet" href="static/css/bootstrap.min.css">
 | 
				
			||||||
 | 
					    <link rel="stylesheet" href="static/css/custom.css">
 | 
				
			||||||
 | 
					</head>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<body>
 | 
				
			||||||
 | 
					    <div class="container mb-5" id="banner">
 | 
				
			||||||
 | 
					        <div class="row">
 | 
				
			||||||
 | 
					            <div class="col-auto">
 | 
				
			||||||
 | 
					                <img src="static/image/logo.png" height="200px">
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					            <div class="col my-auto">
 | 
				
			||||||
 | 
					                <h1>botamusique Web Interface</h1>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <div class="container" style="max-width: 800px">
 | 
				
			||||||
 | 
					        <h3>Token from the {{ name }} bot needed.<br />Please send "{{ command }}" to the bot in mumble</h3>
 | 
				
			||||||
 | 
					        <form action="." method="get">
 | 
				
			||||||
 | 
					          <div class="form-group">
 | 
				
			||||||
 | 
					           <label for="token_input">Token</label>
 | 
				
			||||||
 | 
					            <input type="password" class="form-control" id="token_input" name="token">
 | 
				
			||||||
 | 
					          </div>
 | 
				
			||||||
 | 
					          <button type="submit" class="btn btn-primary">Submit</button>
 | 
				
			||||||
 | 
					        </form>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <div class="floating-button" style="bottom: 50px;" onclick="switchTheme()">
 | 
				
			||||||
 | 
					        <i class="fas fa-lightbulb" aria-hidden="true"></i>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <script src="static/js/jquery-3.5.1.min.js"></script>
 | 
				
			||||||
 | 
					    <script src="static/js/popper.min.js"></script>
 | 
				
			||||||
 | 
					    <script src="static/js/bootstrap.min.js"></script>
 | 
				
			||||||
 | 
					    <script src="static/js/fontawesome.all.min.js"></script>
 | 
				
			||||||
 | 
					    <script src="static/js/custom.js"></script>
 | 
				
			||||||
 | 
					</body>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user