Skip to content
Snippets Groups Projects
Commit 422da996 authored by Mitchell Moore's avatar Mitchell Moore Committed by Krish Moodbidri
Browse files

Added UAB OnDemand header, basic code cleanup, fixed redirect args to fix rerouting back to index

- Changed UAB OnDemand header and removed static folder
- Remove extra form fields
- Fixed user name population issue.
- Fixed redirect loop
- (fix) Prevent app from routing back to index
- Update readme
- (fix) Registration script call
- (fix) Jinja Version Update
- (fix) incorrect redir argument
- (fix) removed hardcoded return value
- Combine index and SignUp routes
- (fix) get redir args
- (fix) localize css elements
parent c5a1aa6f
No related branches found
No related tags found
No related merge requests found
...@@ -7,15 +7,17 @@ git clone https://gitlab.rc.uab.edu/mmoo97/flask_user_reg.git ...@@ -7,15 +7,17 @@ git clone https://gitlab.rc.uab.edu/mmoo97/flask_user_reg.git
``` ```
## Prerequisites ## Prerequisites
- Ensure `pip` is installed (see: https://packaging.python.org/guides/installing-using-pip-and-virtualenv/ ) - Ensure `pip` is installed (see: https://packaging.python.org/guides/installing-using-pip-and-virtualenv/ ).
- Install Flask using the `pip` command. Note, to install flask in your own `$HOME` use `pip install --user Flask` - Ensure you have created a virtual environment called `venv` setup within the cloned project.
``` - Install Flask and other dependencies using the following:
pip install Flask
``` ```
pip intall -p requirements.txt
```
- Note, to install flask in your own `$HOME` use `pip install --user Flask`.
## Starting the virtual machine for Flask ## Starting the virtual machine for Flask
- Change to the `formWork` directory - Change to the `flask_user_reg` directory.
- then start virtual machine: - then start virtual machine:
``` ```
source venv/bin/activate source venv/bin/activate
......
...@@ -5,6 +5,7 @@ from __future__ import print_function ...@@ -5,6 +5,7 @@ from __future__ import print_function
import os import os
import sys import sys
import subprocess
# third-party imports # third-party imports
from flask import Flask, redirect, url_for, request from flask import Flask, redirect, url_for, request
...@@ -16,6 +17,7 @@ def create_app(config_name): ...@@ -16,6 +17,7 @@ def create_app(config_name):
app = Flask(__name__) app = Flask(__name__)
Bootstrap(app) Bootstrap(app)
global return_url global return_url
return_url = '' return_url = ''
...@@ -24,39 +26,40 @@ def create_app(config_name): ...@@ -24,39 +26,40 @@ def create_app(config_name):
global return_url global return_url
print(username, name, return_url, file=sys.stdout) print(username, name, return_url, file=sys.stdout)
# Deliver arguments to script. # Deliver arguments to script.
tempString = 'sudo user_create ' + username + " " + name tempString = 'ssh ohpc "sudo /opt/ohpc_user_create/user_create ' + username + ' \'' + name + '\'"'
os.system("ssh ohpc " + tempString) print(tempString, file=sys.stdout)
output = subprocess.check_output([tempString], shell=True)
print(output.split('\n')[7], file=sys.stdout)
return redirect(return_url, 302) return redirect(return_url, 302)
@app.route('/', methods=['GET']) @app.route('/', methods=['GET', 'POST'])
def index(): def index():
global return_url
return_url = request.args.get("redir")
user = request.remote_user user = request.remote_user
return render_template("auth/SignUp.html", user=user, url=return_url) if request.method == 'GET':
@app.route('/', methods=['GET', 'POST']) global return_url
def SignUp():
name = request.form['name'] return_url = request.args.get("redir")[0] or "/pun/sys/dashboard"
user = request.remote_user return render_template("auth/SignUp.html", user=user)
if request.method == 'GET': if request.method == 'POST':
return render_template("auth/SignUp.html", user=user) name = request.form['name']
if request.method == 'POST' and name != "": if name != "":
return redirect(url_for('success', username=str(user), name=name)) return redirect(url_for('success', username=str(user), name=name))
else: else:
return render_template("auth/SignUp.html", user=user) return render_template("auth/SignUp.html", user=user)
@app.errorhandler(403) @app.errorhandler(403)
def forbidden(error): def forbidden(error):
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
<html class="gr__rc_uab_edu"><head> <html class="gr__rc_uab_edu"><head>
<title>User Register</title> <title>User Register</title>
<link rel="shortcut icon" type="image/x-icon" href="/public/favicon.ico"> <link rel="shortcut icon" type="image/x-icon" href="/public/favicon.ico">
<link rel="stylesheet" media="all" href="/static/style/application.css"> <link rel="stylesheet" media="all" href="/register/static/style/application.css">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<style> <style>
...@@ -14,26 +14,51 @@ ...@@ -14,26 +14,51 @@
</head> </head>
<body data-gr-c-s-loaded="true"> <body data-gr-c-s-loaded="true">
<header> <header>
<nav class="navbar navbar-inverse navbar-static-top"> <nav class="navbar navbar-inverse navbar-static-top">
<div class="container-fluid"> <div class="navbar-header">
<div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
<a class="navbar-brand" href="/register">Research Computing</a> </div><div class="container-fluid">
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9"> <div class="navbar-collapse collapse" id="bs-example-navbar-collapse-9" style="">
<ul class="nav navbar-nav"> <a class="navbar-brand" href="/pun/sys/dashboard/">UAB Research Computing </a><div class="navbar-right">
<ul class="nav navbar-nav" style="float: right;">
</ul>
<div class="navbar-right"> <li class="dropdown" title="Help">
<ul class="nav navbar-nav"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<li> <span class="hidden-sm hidden-sm-nav"> Help</span>
<a target="_blank" href="https://docs.uabgrid.uab.edu/wiki/Cheaha_GettingStarted"> </a>
<i class="fas fa-info-circle fa-fw"></i> Online Documentation <ul class="dropdown-menu">
</a></li>
<li>
</li></ul> <li>
</div> <a target="_blank" href="https://docs.uabgrid.uab.edu/wiki/Cheaha_GettingStarted">
</div> <i class="fas fa-info-circle fa-fw"></i> Online Documentation
</a></li>
<li>
<a target="_self" href="/nginx/stop?redir=/pun/sys/dashboard/">
<i class="fas fa-sync fa-fw"></i> Restart Web Server
</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav" style="
float: right;
">
<li>
</li></ul>
</div><ul class="nav navbar-nav">
<ul class="dropdown-menu">
</ul>
</ul></div>
</div> </div>
</nav> </nav>
</header> </header>
...@@ -43,24 +68,13 @@ ...@@ -43,24 +68,13 @@
"> ">
<div class="col-md-12"> <div class="col-md-12">
<img class="header-logo" height="100" style="margin-bottom: 20px" <img="" src="/static/img/cheaha-logo-a605de0aecd3006b82a5ee30a6d0cb8cd9bf8b7e836296cc293eac746a4c2b11.png"> <img class="header-logo" height="100" style="margin-bottom: 20px" src="/register/static/img/cheaha-logo-a605de0aecd3006b82a5ee30a6d0cb8cd9bf8b7e836296cc293eac746a4c2b11.png">
<h1>Welcome</h1> <h2>Hello, {{ user }}!</h2>
<h2>Hello user</h2>
<form action="/" method="post"> <form action="." method="post">
<div class="signUpContainer"> <div class="signUpContainer">
<label for="name"><b>Full Name:<br></b></label> <label for="name"><b>Full Name:<br></b></label>
<input class="form-control" type="text" placeholder="Enter Full Name" name="name"> <input class="form-control" type="text" placeholder="Enter Full Name" name="name">
<label for="email"><b>Email:<br></b></label>
<input class="form-control" type="text" placeholder="Enter Email Address" name="email">
<label for="institution"><b>Institution:<br></b></label>
<input class="form-control" type="text" placeholder="Enter Institution" name="institution">
<label for="sponsor"><b>Sponsor or Affiliation:<br></b></label>
<input class="form-control" type="text" placeholder="Enter Sponsor or Affiliation" name="sponsor">
<input class="btn btn-primary btn-block" type="submit" value="submit" onclick="return empty()"> <input class="btn btn-primary btn-block" type="submit" value="submit" onclick="return empty()">
</div> </div>
</form> </form>
...@@ -73,7 +87,7 @@ ...@@ -73,7 +87,7 @@
<div class="row"> <div class="row">
<div class="col-md-6 col-sm-6"> <div class="col-md-6 col-sm-6">
<a href="https://osc.github.io/Open-OnDemand/"> <a href="https://osc.github.io/Open-OnDemand/">
<img class="footer-logo" alt="Powered by Open OnDemand" height="40" style="margin-bottom: 20px" src="/static/img/OpenOnDemand_powered_by_RGB-cb3aad5ff5350c7994f250fb334ddcc72e343233ce99eb71fda93beddd76a847.svg"> <img class="footer-logo" alt="Powered by Open OnDemand" height="40" style="margin-bottom: 20px" src="/register/static/img/OpenOnDemand_powered_by_RGB-cb3aad5ff5350c7994f250fb334ddcc72e343233ce99eb71fda93beddd76a847.svg">
</a> </a>
</div> </div>
</div> </div>
......
...@@ -6,7 +6,7 @@ Flask-Login==0.4.1 ...@@ -6,7 +6,7 @@ Flask-Login==0.4.1
Flask-Testing==0.7.1 Flask-Testing==0.7.1
Flask-WTF==0.14.2 Flask-WTF==0.14.2
itsdangerous==1.1.0 itsdangerous==1.1.0
Jinja2==2.10 Jinja2>=2.10.1
Mako==1.0.7 Mako==1.0.7
MarkupSafe==1.1.1 MarkupSafe==1.1.1
pbr==5.1.3 pbr==5.1.3
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment