add reset password functionality
parent
34d47ad39f
commit
a009450caa
@ -1,23 +1,43 @@
|
||||
from wowstash.library.jsonrpc import wallet
|
||||
from wowstash.models import Transaction
|
||||
from wowstash.factory import db
|
||||
import click
|
||||
from flask import Blueprint, url_for
|
||||
|
||||
import wowstash.models
|
||||
from wowstash.library.docker import docker
|
||||
from wowstash.models import User, PasswordReset
|
||||
from wowstash.factory import db, bcrypt
|
||||
|
||||
# @app.errorhandler(404)
|
||||
def not_found(error):
|
||||
return make_response(jsonify({
|
||||
'error': 'Page not found'
|
||||
}), 404)
|
||||
|
||||
# @app.cli.command('initdb')
|
||||
def init_db():
|
||||
bp = Blueprint("cli", "cli", cli_group=None)
|
||||
|
||||
|
||||
@bp.cli.command('clean_containers')
|
||||
def clean_containers():
|
||||
docker.cleanup()
|
||||
|
||||
@bp.cli.command('reset_wallet')
|
||||
@click.argument('user_id')
|
||||
def reset_wallet(user_id):
|
||||
user = User.query.get(user_id)
|
||||
user.clear_wallet_data()
|
||||
print(f'Wallet data cleared for user {user.id}')
|
||||
|
||||
@bp.cli.command('init')
|
||||
def init():
|
||||
db.create_all()
|
||||
|
||||
# @app.cli.command('send_transfers')
|
||||
def send_transfers():
|
||||
txes = Transaction.query.all()
|
||||
for i in txes:
|
||||
print(i)
|
||||
# tx = wallet.transfer(
|
||||
# 0, current_user.subaddress_index, address, amount
|
||||
# )
|
||||
@bp.cli.command('reset_password')
|
||||
@click.argument('user_email')
|
||||
@click.argument('duration')
|
||||
def reset_password(user_email, duration):
|
||||
user = User.query.filter(User.email==user_email).first()
|
||||
if not user:
|
||||
click.echo('[!] Email address does not exist!')
|
||||
|
||||
pwr = PasswordReset(
|
||||
user=user.id,
|
||||
hash=PasswordReset().generate_hash(),
|
||||
expiration_hours=duration
|
||||
)
|
||||
db.session.add(pwr)
|
||||
db.session.commit()
|
||||
click.echo(f'[+] Password reset link #{pwr.id} for {user_email} expires in {duration} hours: {url_for("auth.reset", hash=pwr.hash)}')
|
||||
|
@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
{% include 'head.html' %}
|
||||
|
||||
<body id="page-top">
|
||||
|
||||
{% include 'navbar.html' %}
|
||||
|
||||
<!-- <header class="masthead">
|
||||
<div class="container h-100">
|
||||
<div class="row h-100">
|
||||
<div class="col-lg-12 my-auto">
|
||||
<div class="header-content mx-auto">
|
||||
<h1 class="mb-4">Reset your password</h1>
|
||||
<p>Wownero is a privacy centric cryptocurrency and is most safely managed on your own personal devices, on your own network, and with your own copy of the blockchain. This is a publicly accessible website, and while strict security measures are implemented on our servers, your account's security <strong>cannot</strong> be guaranteed. </p>
|
||||
<p>If you decide to use this site for managing your funds, you do so at your own risk and are bound by the terms and conditions of this site. Practice good operational security and do not use this site for large amounts of funds.</p>
|
||||
<div>
|
||||
<a href="{{ url_for('meta.faq') }}">FAQ</a> -
|
||||
<a href="{{ url_for('meta.terms') }}">Terms</a> -
|
||||
<a href="{{ url_for('meta.privacy') }}">Privacy</a>
|
||||
</div><br>
|
||||
<a href="#register" class="btn btn-outline btn-xl js-scroll-trigger">Proceed</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header> -->
|
||||
|
||||
<section class="section1" id="reset">
|
||||
<div class="container">
|
||||
<div class="section-heading text-center">
|
||||
<form method="POST" action="">
|
||||
{{ form.csrf_token }}
|
||||
{% for f in form %}
|
||||
{% if f.name != 'csrf_token' %}
|
||||
{% if f.type == 'BooleanField' %}
|
||||
<div class="form-group-span">
|
||||
{{ f.label }}
|
||||
{{ f }}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="form-group">
|
||||
{{ f.label }}
|
||||
{{ f }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<ul>
|
||||
{% for field, errors in form.errors.items() %}
|
||||
<li>{{ form[field].label }}: {{ ', '.join(errors) }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<input type="submit" value="Reset" class="btn btn-link btn-outline-inverse btn-xl">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% include 'footer.html' %}
|
||||
|
||||
{% include 'scripts.html' %}
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue