otp password
This commit is contained in:
parent
c0a13afe13
commit
a2857083a8
|
@ -20,17 +20,17 @@ def login():
|
|||
login_user(user, remember=form.remember_me.data)
|
||||
next_page = request.args.get('next')
|
||||
if not next_page or url_parse(next_page).netloc != '':
|
||||
next_page = url_for('auth/otp_login.html')
|
||||
next_page = url_for('auth.otp_login')
|
||||
return redirect(next_page)
|
||||
return render_template('auth/login.html', title=_('Sign In'), form=form)
|
||||
|
||||
def auth_opt():
|
||||
@bp.route('/otp', methods=['GET', 'POST'])
|
||||
def otp_login():
|
||||
form = OTPForm()
|
||||
if OTP != user.curr_otp :
|
||||
flash(_('Invalid OTP'))
|
||||
if form.validate_on_submit():
|
||||
return redirect(url_for('main.index'))
|
||||
|
||||
return render_template('auth/otp_login.html', title=_('Enter OTP'),
|
||||
form=form)
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ class User(UserMixin, PaginatedAPIMixin, db.Model):
|
|||
password_hash = db.Column(db.String(128))
|
||||
posts = db.relationship('Post', backref='author', lazy='dynamic')
|
||||
about_me = db.Column(db.String(140))
|
||||
otp = db.Column(db.String(4), index=True, unique=True)
|
||||
otp = db.Column(db.String(4))
|
||||
last_seen = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
token = db.Column(db.String(32), index=True, unique=True)
|
||||
token_expiration = db.Column(db.DateTime)
|
||||
|
@ -119,11 +119,12 @@ class User(UserMixin, PaginatedAPIMixin, db.Model):
|
|||
def __repr__(self):
|
||||
return '<User {}>'.format(self.username)
|
||||
|
||||
def set_otp(self, otp):
|
||||
self.otp = otp
|
||||
##
|
||||
## def set_otp(self, otp):
|
||||
## self.otp = otp
|
||||
|
||||
def get_otp(self):
|
||||
return self.otp
|
||||
## def get_otp(self):
|
||||
## return self.otp
|
||||
|
||||
def set_password(self, password):
|
||||
self.password_hash = generate_password_hash(password)
|
||||
|
|
Binary file not shown.
|
@ -23,6 +23,7 @@ def upgrade():
|
|||
sa.Column('username', sa.String(length=64), nullable=True),
|
||||
sa.Column('email', sa.String(length=120), nullable=True),
|
||||
sa.Column('password_hash', sa.String(length=128), nullable=True),
|
||||
sa.Column('otp', sa.Integer()),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
|
||||
|
|
Loading…
Reference in New Issue