예제 #1
0
 def dispatch_request(self, id):
     super(WalletUnlockView, self).dispatch_request(id)
     otpsetting = session.query(Setting).get('otpsecret')
     if otpsetting:
         form = OTPUnlockForm(request.form)
         secret = otpsetting.value
         otp_valid = otp.valid_totp(token=form.otp.data, secret=secret)
     else:
         form = UnlockForm(request.form)
         otp_valid = True
     if request.method == 'POST' and form.validate() and otp_valid:
         flash("OTP valid", "success")
         try:
             ret = self.conn.walletpassphrase(form.passphrase.data,
                                                          form.timeout.data)
             flash('Wallet unlocked', 'success')
             return redirect(url_for('wallet.wallet_detail',
                                                         id=self.wallet.id))
         except WalletPassphraseIncorrect:
             flash('Passphrase incorrect', 'error')
         except WalletAlreadyUnlocked:
             flash('Wallet already unlocked', 'error')
     elif request.method == 'POST' and form.validate() and not otp_valid:
         flash("OTP invalid", "error")
     return render_template('wallet/wallet/unlock.html', wallet=self.wallet,
                            form=form)
예제 #2
0
 def dispatch_request(self, id):
     super(WalletUnlockView, self).dispatch_request(id)
     otpsetting = session.query(Setting).get('otpsecret')
     if otpsetting:
         form = OTPUnlockForm(request.form)
         secret = otpsetting.value
         otp_valid = otp.valid_totp(token=form.otp.data, secret=secret)
     else:
         form = UnlockForm(request.form)
         otp_valid = True
     if request.method == 'POST' and form.validate() and otp_valid:
         flash("OTP valid", "success")
         try:
             ret = self.conn.walletpassphrase(form.passphrase.data,
                                              form.timeout.data)
             flash('Wallet unlocked', 'success')
             return redirect(
                 url_for('wallet.wallet_detail', id=self.wallet.id))
         except WalletPassphraseIncorrect:
             flash('Passphrase incorrect', 'error')
         except WalletAlreadyUnlocked:
             flash('Wallet already unlocked', 'error')
     elif request.method == 'POST' and form.validate() and not otp_valid:
         flash("OTP invalid", "error")
     return render_template('wallet/wallet/unlock.html',
                            wallet=self.wallet,
                            form=form)
예제 #3
0
 def test_setval_int(self):
     key = 'test_setval_int'
     value = '94'
     newsetting = Setting(key, value)
     session.add(newsetting)
     session.commit()
     setting = session.query(Setting).get(key)
     self.assertEqual(
         setting.value_decrypted,
         value,
         "Setting incorrectly saved",
     )
예제 #4
0
 def test_setval_int(self):
     key = 'test_setval_int'
     value = '94'
     newsetting = Setting(key, value)
     session.add(newsetting)
     session.commit()
     setting = session.query(Setting).get(key)
     self.assertEqual(
         setting.value_decrypted,
         value,
         "Setting incorrectly saved",
     )
예제 #5
0
 def get_secret(self):
     """
     Cryptographically-secure 10 byte random key, presented to the user as
     a base32 16-character string.
     """
     name = 'otpsecret'
     setting = session.query(Setting).get(name)
     if setting:
         ret = False
     else:
         secret = get_random_bytes(10)
         code = b32encode(secret)
         setting = Setting(name, code)
         session.add(setting)
         session.commit()
         ret = code
     return ret
예제 #6
0
 def dispatch_request(self, id):
     self.wallet = session.query(Wallet).get(id)
     if not self.wallet:
         abort(404)
예제 #7
0
 def dispatch_request(self, id):
     self.wallet = session.query(Wallet).get(id)
     if not self.wallet:
         abort(404)