Fakultas Ilmu Komputer UI

Commit 58e7e503 authored by zakiraihan's avatar zakiraihan
Browse files

Add logout from sso and change phone number

parent a346ff30
......@@ -138,5 +138,34 @@ def createSSOAccount():
def renderFailedToLoginSSO():
return render_template('failedToLoginSSO.html')
@app.route('/logoutsso', methods=['POST'])
def renderLogoutStatus():
from telebot.utils import logoutSSOUser
username = request.form['username']
logoutStatus = logoutSSOUser(username)
if (logoutStatus == 'success'):
return render_template('successToLogoutSSO.html', username=username)
else:
return render_template('failedToLogoutSSO.html', username=username)
@app.route('/changePhoneNumber', methods=['POST'])
def renderChangePassword():
from telebot.utils import getAccountCurrentPhoneNumber
username = request.form['username']
phoneNumber = getAccountCurrentPhoneNumber(username)
return render_template('changePhoneNumber.html', username=username, currentPhoneNumber=phoneNumber)
@app.route('/changePhoneNumber/submit', methods=['POST'])
def renderChangePhoneNumberResult():
from telebot.utils import changeAccountPhoneNumber
username = request.form['username']
phoneNumber = request.form['phoneNumber']
changePhoneNumberStatus = changeAccountPhoneNumber(username, phoneNumber)
if (changePhoneNumberStatus == 'success'):
return render_template('successChangePhoneNumber.html', username=username, phoneNumber=phoneNumber)
else:
return render_template('failedChangePhoneNumber.html', username=username)
if __name__ == '__main__':
app.run(threaded=True)
\ No newline at end of file
......@@ -16,4 +16,29 @@ def create_user_sso_account(username, phoneNumber):
def check_if_user_exist(username):
checkAccountExistance = AccountModel.query.filter(AccountModel.ssoId==str(username)).first()
return checkAccountExistance != None
\ No newline at end of file
return checkAccountExistance != None
def logoutSSOUser(username):
checkAccountExistance = AccountModel.query.filter(AccountModel.ssoId==str(username)).first()
try:
checkAccountExistance.delete()
return "success"
except Exception as e:
return "error"
def getAccountCurrentPhoneNumber(username):
checkAccountExistance = AccountModel.query.filter(AccountModel.ssoId==str(username)).first()
try:
return checkAccountExistance.phoneNumber
except Exception as e:
return "error"
def changeAccountPhoneNumber(username, newPhoneNumber):
checkAccountExistance = AccountModel.query.filter(AccountModel.ssoId==str(username)).first()
try:
checkAccountExistance.phoneNumber = newPhoneNumber
checkAccountExistance.update()
return "success"
except Exception as e:
return "error"
\ No newline at end of file
......@@ -29,8 +29,15 @@
</p>
</div>
<div class="row ssoContent d-flex justify-content-around align-items-center">
<a href="/logoutsso" class="btn btn-primary ssoBtn" role="button">Logout SSO</a>
<a href="/changePhoneNumber" class="btn btn-primary ssoBtn" role="button">Change Phone Number</a>
<form class="logoutSSO" action="/logoutsso" method="post">
<input type="hidden" name="username" value="{{ username }}"/>
<button class="btn btn-primary ssoBtn" role="button" type="submit">Logout SSO</button>
</form>
<form class="changePhoneNumber" action="/changePhoneNumber" method="post">
<input type="hidden" name="username" value="{{ username }}"/>
<button class="btn btn-primary ssoBtn" role="button" type="submit">Change Phone Number</button>
</form>
</div>
</div>
</div>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta content='width=device-width, initial-scale=1' name='viewport' />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Login Fasilkom Telegram Bot</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://sso.ui.ac.id/cas/themes/ui/sso.css" />
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/default.css') }}">
<link rel="icon" href="https://sso.ui.ac.id/cas/themes/ui/logo2_0.gif" type="image/x-icon" />
</head>
<body>
<div class="container d-flex justify-content-center">
<div class="makeSureBox">
<div class="row d-flex justify-content-center boxTitle" >
<h5 style="text-align:center;">Fasilkom Telegram Bot Notification</h5>
</div>
<div style='clear:both'></div>
<br>
<div class="row ssoContent">
<p style="text-align:justify;">
Untuk menghubungkan akun telegram dan sso diperlukan nomor telefon yang terdaftar pada telegram.
</p>
<p style="text-align:justify;">
Pastikan nomor telefon yang dimasukkan merupakan nomor yang digunakan pada akun telegram anda.
</p>
</div>
<div class="row ssoContent d-flex justify-content-center align-items-center">
<form class="phoneSubmit" action="/changePhoneNumber/submit" method="post">
<div class="form-group">
<label for="username">Username SSO:</label>
<input id="username" name="username" class="form-control" type="text" value="{{ username }}" readonly/>
</div>
<div class="form-group">
<label for="currentPhoneNumber">Current Phone Number:</label>
<input id="currentPhoneNumber" name="currentPhoneNumber" class="form-control" type="text" value="{{ currentPhoneNumber }}" readonly/>
</div>
<div class="form-group">
<label for="phoneNumber">New Telegram Phone Number:</label>
<input id="phoneNumber" name="phoneNumber" class="form-control" placeholder="ex: 6281319053724" type="text" value=""/>
</div>
<div class="row d-flex justify-content-center align-items-center">
<button class="btn btn-primary ssoBtn" role="button" type="submit">Login SSO</button>
</div>
</form>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta content='width=device-width, initial-scale=1' name='viewport' />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Login Fasilkom Telegram Bot</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://sso.ui.ac.id/cas/themes/ui/sso.css" />
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/default.css') }}">
<link rel="icon" href="https://sso.ui.ac.id/cas/themes/ui/logo2_0.gif" type="image/x-icon" />
</head>
<body>
<div class="container d-flex justify-content-center">
<div class="makeSureBox">
<div class="row d-flex justify-content-center boxTitle" >
<h5 style="text-align:center;">Fasilkom Telegram Bot Notification</h5>
</div>
<div style='clear:both'></div>
<br>
<div class="row ssoContent">
<p style="text-align:justify;">
Mohon maaf proses pergantian nomor telepon gagal, silahkan coba kembali nanti.
</p>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta content='width=device-width, initial-scale=1' name='viewport' />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Login Fasilkom Telegram Bot</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://sso.ui.ac.id/cas/themes/ui/sso.css" />
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/default.css') }}">
<link rel="icon" href="https://sso.ui.ac.id/cas/themes/ui/logo2_0.gif" type="image/x-icon" />
</head>
<body>
<div class="container d-flex justify-content-center">
<div class="makeSureBox">
<div class="row d-flex justify-content-center boxTitle" >
<h5 style="text-align:center;">Fasilkom Telegram Bot Notification</h5>
</div>
<div style='clear:both'></div>
<br>
<div class="row ssoContent">
<p style="text-align:justify;">
Mohon maaf proses logout untuk akun {{ username }} gagal, silahkan coba beberapa saat lagi.
</p>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta content='width=device-width, initial-scale=1' name='viewport' />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Login Fasilkom Telegram Bot</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://sso.ui.ac.id/cas/themes/ui/sso.css" />
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/default.css') }}">
<link rel="icon" href="https://sso.ui.ac.id/cas/themes/ui/logo2_0.gif" type="image/x-icon" />
</head>
<body>
<div class="container d-flex justify-content-center">
<div class="makeSureBox">
<div class="row d-flex justify-content-center boxTitle" >
<h5 style="text-align:center;">Fasilkom Telegram Bot Notification</h5>
</div>
<div style='clear:both'></div>
<br>
<div class="row ssoContent">
<p style="text-align:justify;">
Anda telah berhasil mengganti nomor telepon untuk username: {{ username }} menjadi +{{ phoneNumber }}, silahkan tutup jendela ini.
</p>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta content='width=device-width, initial-scale=1' name='viewport' />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Login Fasilkom Telegram Bot</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://sso.ui.ac.id/cas/themes/ui/sso.css" />
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/default.css') }}">
<link rel="icon" href="https://sso.ui.ac.id/cas/themes/ui/logo2_0.gif" type="image/x-icon" />
</head>
<body>
<div class="container d-flex justify-content-center">
<div class="makeSureBox">
<div class="row d-flex justify-content-center boxTitle" >
<h5 style="text-align:center;">Fasilkom Telegram Bot Notification</h5>
</div>
<div style='clear:both'></div>
<br>
<div class="row ssoContent">
<p style="text-align:justify;">
Anda telah berhasil logout untuk username: {{ username }}, silahkan tutup jendela ini.
</p>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment