@@ -1785,6 +1785,39 @@ class HAXCMSClass {
1785
1785
this . refreshPrivateKey = uuidv4 ( ) ;
1786
1786
fs . writeFileSync ( path . join ( this . configDirectory , ".rpk" ) , this . refreshPrivateKey ) ;
1787
1787
}
1788
+ // allow for loading in user defined config
1789
+ // pk/rpk test for files that can contain these
1790
+ try {
1791
+ this . user = JSON . parse ( fs . readFileSync ( path . join ( this . configDirectory , ".user" ) ) ,
1792
+ { encoding :'utf8' , flag :'r' } , 'utf8' ) ;
1793
+ this . superUser = { ...this . user } ;
1794
+ }
1795
+ catch ( e ) {
1796
+ console . warn ( '***************************************************************' ) ;
1797
+ console . warn ( '\nHAXcms USER CONFIGURATION FILE NOT FOUND, creating default user' ) ;
1798
+ console . warn ( `${ path . join ( this . configDirectory , ".user" ) } is being created with default credentials` ) ;
1799
+ console . warn ( "MAKE SURE YOU EDIT THIS FILE IF PUTTING IN PRODUCTION!!!!!" ) ;
1800
+ console . warn ( "username: admin" ) ;
1801
+ console . warn ( "password: admin" ) ;
1802
+ console . warn ( "\n***************************************************************" ) ;
1803
+ // create a default user
1804
+ this . superUser = {
1805
+ name : 'admin' ,
1806
+ password : 'admin' ,
1807
+ } ;
1808
+ this . user = {
1809
+ name : 'admin' ,
1810
+ password : 'admin' ,
1811
+ } ;
1812
+ fs . writeFileSync ( path . join ( this . configDirectory , ".user" ) , JSON . stringify ( this . user , null , 2 ) ) ;
1813
+ }
1814
+ // warn if we have default credentials
1815
+ if ( this . user . name == 'admin' && this . user . password == 'admin' ) {
1816
+ console . warn ( '***************************************************************' ) ;
1817
+ console . warn ( '\nHAXcms USER CONFIGURATION FILE HAS DEFAULT CREDENTIALS, change them!!' ) ;
1818
+ console . warn ( `\n${ path . join ( this . configDirectory , ".user" ) } ` ) ;
1819
+ console . warn ( "\n***************************************************************" ) ;
1820
+ }
1788
1821
}
1789
1822
/**
1790
1823
* Load a site off the file system with option to create
@@ -2661,7 +2694,7 @@ class HAXCMSClass {
2661
2694
let refreshToken = req . cookies [ 'haxcms_refresh_token' ] ;
2662
2695
// if there isn't one then we have to bail hard
2663
2696
if ( ! refreshToken ) {
2664
- res . send ( 401 ) ;
2697
+ res . sendStatus ( 401 ) ;
2665
2698
}
2666
2699
// if there is a refresh token then decode it
2667
2700
let refreshTokenDecoded = this . decodeRefreshToken ( refreshToken ) ;
@@ -2681,7 +2714,7 @@ class HAXCMSClass {
2681
2714
// kick back the end if its invalid
2682
2715
if ( endOnInvalid ) {
2683
2716
res . cookie ( 'haxcms_refresh_token' , '1' , { maxAge : 1 } ) ;
2684
- res . send ( 401 ) ;
2717
+ res . sendStatus ( 401 ) ;
2685
2718
}
2686
2719
return false ;
2687
2720
}
@@ -2701,7 +2734,7 @@ class HAXCMSClass {
2701
2734
return true ;
2702
2735
}
2703
2736
else {
2704
- usr = { } ;
2737
+ let usr = { } ;
2705
2738
usr . name = name ;
2706
2739
usr . grantAccess = false ;
2707
2740
// fire custom event for things to respond to as needed
@@ -2734,7 +2767,6 @@ class HAXCMSClass {
2734
2767
else {
2735
2768
let usr = { } ;
2736
2769
usr . name = name ;
2737
- usr . password = pass ;
2738
2770
usr . adminFallback = adminFallback ;
2739
2771
usr . grantAccess = false ;
2740
2772
// fire custom event for things to respond to as needed
0 commit comments