File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " krist" ,
3- "version" : " 3.5.1 " ,
3+ "version" : " 3.5.2 " ,
44 "description" : " The new Krist node written in TypeScript." ,
55 "type" : " module" ,
66 "scripts" : {
Original file line number Diff line number Diff line change @@ -69,7 +69,9 @@ export async function verifyAddress(
6969 return { authed : true , address : newAddress } ;
7070 }
7171
72- if ( address . privatekey ) { // Address exists, auth if the privatekey is equal
72+ // Address exists, auth if the privatekey is equal, or handle the locked flow if it's locked (even if there's no
73+ // privatekey set)
74+ if ( address . privatekey || address . locked ) {
7375 const authed = ! address . locked && address . privatekey === hash ;
7476
7577 if ( authed ) {
Original file line number Diff line number Diff line change 2020 */
2121
2222import { expect } from "chai" ;
23+ import { Address } from "../../src/database/index.js" ;
2324import { api } from "../api.js" ;
2425import { seed } from "../seed.js" ;
2526
@@ -56,5 +57,21 @@ describe("v2 routes: login", function() {
5657 expect ( res ) . to . be . json ;
5758 expect ( res . body ) . to . deep . include ( { ok : true , authed : true , address : "k8juvewcui" } ) ;
5859 } ) ;
60+
61+ it ( "should error for locked addresses even without a privatekey" , async function ( ) {
62+ const address = await Address . findOne ( { where : { address : "kwsgj3x184" } } ) ;
63+ if ( ! address ) throw new Error ( "Address not found" ) ;
64+
65+ const oldPrivatekey = address . privatekey ;
66+ address . privatekey = null ;
67+ await address . save ( ) ;
68+
69+ const res = await api ( ) . post ( "/login" ) . send ( { privatekey : "c" } ) ;
70+ expect ( res ) . to . be . json ;
71+ expect ( res . body ) . to . deep . include ( { ok : true , authed : false } ) ;
72+
73+ address . privatekey = oldPrivatekey ;
74+ await address . save ( ) ;
75+ } ) ;
5976 } ) ;
6077} ) ;
You can’t perform that action at this time.
0 commit comments