mirror of
https://github.com/WGDashboard/WGDashboard.git
synced 2026-12-01 17:07:47 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c897834e1 | ||
|
|
0a9f37cd2e | ||
|
|
a00799c3c5 | ||
|
|
dec86ad222 | ||
|
|
e547a83776 |
@@ -33,6 +33,7 @@ pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
dist
|
||||
/src/static/.dist-staging.*
|
||||
|
||||
node_modules
|
||||
.DS_Store
|
||||
|
||||
+5
-5
@@ -113,10 +113,12 @@ def createClientBlueprint(wireguardConfigurations: dict[WireguardConfiguration],
|
||||
return ResponseObject(False, "Please provide a valid Email")
|
||||
|
||||
token = dashboardClients.GenerateClientPasswordResetToken(u.get('ClientID'))
|
||||
if not token:
|
||||
return ResponseObject(False, "A reset token was recently sent. Please wait 2 minutes before requesting another.")
|
||||
|
||||
status, msg = emailSender.send(
|
||||
email, "[WGDashboard | Client] Reset Password",
|
||||
f"Hi {email}, \n\nIt looks like you're trying to reset your password at {date} \n\nEnter this 6 digits code on the Forgot Password to continue:\n\n{token}\n\nThis code will expire in 30 minutes for your security. If you didn’t request a password reset, you can safely ignore this email—your current password will remain unchanged.\n\nIf you need help, feel free to contact support.\n\nBest regards,\n\nWGDashboard"
|
||||
f"Hi {email}, \n\nIt looks like you're trying to reset your password at {date} \n\nEnter this reset token on the Forgot Password page to continue:\n\n{token}\n\nThis token will expire in 30 minutes for your security. If you didn’t request a password reset, you can safely ignore this email—your current password will remain unchanged.\n\nIf you need help, feel free to contact support.\n\nBest regards,\n\nWGDashboard"
|
||||
)
|
||||
|
||||
return ResponseObject(status, msg)
|
||||
@@ -150,11 +152,9 @@ def createClientBlueprint(wireguardConfigurations: dict[WireguardConfiguration],
|
||||
return ResponseObject(False, "Please provide a valid Email")
|
||||
|
||||
if not dashboardClients.ValidateClientPasswordResetToken(u.get('ClientID'), token):
|
||||
return ResponseObject(False, "Verification code is either invalid or expired")
|
||||
return ResponseObject(False, "Reset token is either invalid or expired")
|
||||
|
||||
status, msg = dashboardClients.ResetClientPassword(u.get('ClientID'), password, confirmPassword)
|
||||
|
||||
dashboardClients.RevokeClientPasswordResetToken(u.get('ClientID'), token)
|
||||
status, msg = dashboardClients.ResetClientPassword(u.get('ClientID'), password, confirmPassword, token)
|
||||
|
||||
return ResponseObject(status, msg)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import datetime
|
||||
import hashlib
|
||||
import random
|
||||
import secrets
|
||||
import uuid
|
||||
|
||||
import bcrypt
|
||||
@@ -305,7 +305,9 @@ class DashboardClients:
|
||||
def GetClientAssignedPeers(self, ClientID):
|
||||
return self.DashboardClientsPeerAssignment.GetAssignedPeers(ClientID)
|
||||
|
||||
def ResetClientPassword(self, ClientID, NewPassword, ConfirmNewPassword) -> tuple[bool, str] | tuple[bool, None]:
|
||||
def ResetClientPassword(
|
||||
self, ClientID, NewPassword, ConfirmNewPassword, ResetToken
|
||||
) -> tuple[bool, str] | tuple[bool, None]:
|
||||
c = self.GetClient(ClientID)
|
||||
if c is None:
|
||||
return False, "Client does not exist"
|
||||
@@ -316,18 +318,36 @@ class DashboardClients:
|
||||
pwStrength, msg = ValidatePasswordStrength(NewPassword)
|
||||
if not pwStrength:
|
||||
return pwStrength, msg
|
||||
|
||||
if not isinstance(ResetToken, str) or not ResetToken or len(ResetToken) > 128:
|
||||
return False, "Reset token is either invalid or expired"
|
||||
|
||||
tokenDigest = hashlib.sha256(ResetToken.encode("utf-8")).hexdigest()
|
||||
now = datetime.datetime.now()
|
||||
try:
|
||||
with self.engine.begin() as conn:
|
||||
tokenClaimed = conn.execute(
|
||||
self.dashboardClientsPasswordResetLinkTable.update().values({
|
||||
"ExpiryDate": now
|
||||
}).where(
|
||||
db.and_(
|
||||
self.dashboardClientsPasswordResetLinkTable.c.ClientID == ClientID,
|
||||
self.dashboardClientsPasswordResetLinkTable.c.ResetToken == tokenDigest,
|
||||
self.dashboardClientsPasswordResetLinkTable.c.ExpiryDate > now
|
||||
)
|
||||
)
|
||||
)
|
||||
if tokenClaimed.rowcount != 1:
|
||||
return False, "Reset token is either invalid or expired"
|
||||
|
||||
conn.execute(
|
||||
self.dashboardClientsTable.update().values({
|
||||
"TotpKeyVerified": None,
|
||||
"TotpKey": pyotp.random_base32(),
|
||||
"Password": bcrypt.hashpw(NewPassword.encode('utf-8'), bcrypt.gensalt()).decode("utf-8"),
|
||||
}).where(
|
||||
self.dashboardClientsTable.c.ClientID == ClientID
|
||||
)
|
||||
)
|
||||
self.logger.log(Message=f"User {ClientID} reset password and TOTP")
|
||||
self.logger.log(Message=f"User {ClientID} reset password")
|
||||
except Exception as e:
|
||||
self.logger.log(Status="false", Message=f"User {ClientID} reset password failed, reason: {str(e)}")
|
||||
return False, "Reset password failed."
|
||||
@@ -420,11 +440,24 @@ class DashboardClients:
|
||||
if c is None:
|
||||
return False
|
||||
|
||||
newToken = str(random.randint(0, 999999)).zfill(6)
|
||||
newToken = secrets.token_urlsafe(32)
|
||||
tokenDigest = hashlib.sha256(newToken.encode("utf-8")).hexdigest()
|
||||
now = datetime.datetime.now()
|
||||
with self.engine.begin() as conn:
|
||||
recentToken = conn.execute(
|
||||
self.dashboardClientsPasswordResetLinkTable.select().where(
|
||||
db.and_(
|
||||
self.dashboardClientsPasswordResetLinkTable.c.ClientID == ClientID,
|
||||
self.dashboardClientsPasswordResetLinkTable.c.CreatedDate > now - datetime.timedelta(minutes=2)
|
||||
)
|
||||
).limit(1)
|
||||
).first()
|
||||
if recentToken:
|
||||
return False
|
||||
|
||||
conn.execute(
|
||||
self.dashboardClientsPasswordResetLinkTable.update().values({
|
||||
"ExpiryDate": datetime.datetime.now()
|
||||
"ExpiryDate": now
|
||||
|
||||
}).where(
|
||||
db.and_(
|
||||
@@ -435,10 +468,10 @@ class DashboardClients:
|
||||
)
|
||||
conn.execute(
|
||||
self.dashboardClientsPasswordResetLinkTable.insert().values({
|
||||
"ResetToken": newToken,
|
||||
"ResetToken": tokenDigest,
|
||||
"ClientID": ClientID,
|
||||
"CreatedDate": datetime.datetime.now(),
|
||||
"ExpiryDate": datetime.datetime.now() + datetime.timedelta(minutes=30)
|
||||
"CreatedDate": now,
|
||||
"ExpiryDate": now + datetime.timedelta(minutes=30)
|
||||
})
|
||||
)
|
||||
|
||||
@@ -446,13 +479,14 @@ class DashboardClients:
|
||||
|
||||
def ValidateClientPasswordResetToken(self, ClientID, Token):
|
||||
c = self.GetClient(ClientID)
|
||||
if c is None:
|
||||
if c is None or not isinstance(Token, str) or not Token or len(Token) > 128:
|
||||
return False
|
||||
tokenDigest = hashlib.sha256(Token.encode("utf-8")).hexdigest()
|
||||
with self.engine.connect() as conn:
|
||||
t = conn.execute(
|
||||
self.dashboardClientsPasswordResetLinkTable.select().where(
|
||||
db.and_(self.dashboardClientsPasswordResetLinkTable.c.ClientID == ClientID,
|
||||
self.dashboardClientsPasswordResetLinkTable.c.ResetToken == Token,
|
||||
self.dashboardClientsPasswordResetLinkTable.c.ResetToken == tokenDigest,
|
||||
self.dashboardClientsPasswordResetLinkTable.c.ExpiryDate > datetime.datetime.now())
|
||||
|
||||
)
|
||||
@@ -460,13 +494,16 @@ class DashboardClients:
|
||||
return t is not None
|
||||
|
||||
def RevokeClientPasswordResetToken(self, ClientID, Token):
|
||||
if not isinstance(Token, str) or len(Token) > 128:
|
||||
return False
|
||||
tokenDigest = hashlib.sha256(Token.encode("utf-8")).hexdigest()
|
||||
with self.engine.begin() as conn:
|
||||
conn.execute(
|
||||
self.dashboardClientsPasswordResetLinkTable.update().values({
|
||||
"ExpiryDate": datetime.datetime.now()
|
||||
}).where(
|
||||
db.and_(self.dashboardClientsPasswordResetLinkTable.c.ClientID == ClientID,
|
||||
self.dashboardClientsPasswordResetLinkTable.c.ResetToken == Token)
|
||||
self.dashboardClientsPasswordResetLinkTable.c.ResetToken == tokenDigest)
|
||||
)
|
||||
)
|
||||
return True
|
||||
|
||||
Generated
+71
-71
@@ -31,7 +31,7 @@
|
||||
"qrcodejs": "^1.0.0",
|
||||
"simple-code-editor": "^2.0.9",
|
||||
"uuid": "^14.0.3",
|
||||
"vue": "^3.5.32",
|
||||
"vue": "^3.5.45",
|
||||
"vue-chartjs": "^5.3.4",
|
||||
"vue-router": "^5.4.0"
|
||||
},
|
||||
@@ -41,9 +41,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/helper-string-parser": {
|
||||
"version": "7.29.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
|
||||
"integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==",
|
||||
"version": "7.29.13",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.13.tgz",
|
||||
"integrity": "sha512-fWegr+WsEsiMVW4KUNdIIzzMTZSzNiqhy0//6+2MRi2d5NFNsL/AYwBQW8eBnRbTBVRnDVzjaJEUqKaCWjMMdQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
@@ -59,12 +59,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/parser": {
|
||||
"version": "7.29.9",
|
||||
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz",
|
||||
"integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==",
|
||||
"version": "7.29.13",
|
||||
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.13.tgz",
|
||||
"integrity": "sha512-fJM50YYjlTiBhgdkGmC1tBpv+FMAyo4annf2X6Aks+0yRlaiVkYW/3f07xAfVVkYIoZ9fFZp+mEThUFnuybhkQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.29.8"
|
||||
"@babel/types": "^7.29.11"
|
||||
},
|
||||
"bin": {
|
||||
"parser": "bin/babel-parser.js"
|
||||
@@ -74,12 +74,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/types": {
|
||||
"version": "7.29.8",
|
||||
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz",
|
||||
"integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==",
|
||||
"version": "7.29.11",
|
||||
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.11.tgz",
|
||||
"integrity": "sha512-WCsemW40Cpc6gouC1SrY6PBaZ+oLRlEVY9XBvZBI7il/HyUrb2nJ505wE1MHEFyDZNnrWDEuy4jL50WVHfTTSQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/helper-string-parser": "^7.29.7",
|
||||
"@babel/helper-string-parser": "^7.29.11",
|
||||
"@babel/helper-validator-identifier": "^7.29.7"
|
||||
},
|
||||
"engines": {
|
||||
@@ -1258,53 +1258,53 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-core": {
|
||||
"version": "3.5.44",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.44.tgz",
|
||||
"integrity": "sha512-k34nCytbK8PQ1gR2mGROYOw6Pnv/mumqIdrZ3x2tbyXZDWm7ViKGLTfdB+DRrWqEQsLgGJvn0WN9jBif5zCTLQ==",
|
||||
"version": "3.5.45",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.45.tgz",
|
||||
"integrity": "sha512-XGHJrM6ufZARAc/w+tyOswStw9tdKiqCKBScI4gGaNxD+aaGu/HQWgKJ+JItjRLPqenQ7iE7G8AJC7T5ew1p+g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.29.9",
|
||||
"@vue/shared": "3.5.44",
|
||||
"@babel/parser": "^7.29.12",
|
||||
"@vue/shared": "3.5.45",
|
||||
"entities": "^7.0.1",
|
||||
"estree-walker": "^2.0.2",
|
||||
"source-map-js": "^1.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-dom": {
|
||||
"version": "3.5.44",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.44.tgz",
|
||||
"integrity": "sha512-W5AoBFWdw1lQAKiHowkfgFKFab82oSRT6sGsPfw/q1GRjsy/ZJFLHGhJyBRIFN9APLTUduDH9U2JAiPOIyKuYg==",
|
||||
"version": "3.5.45",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.45.tgz",
|
||||
"integrity": "sha512-LbP2d19GSOYGPmvMBBCVJVlv7TKtjM1Cfeyu3cYia720pknZP+1cLX7H5MVatvruT6MuJhiPuNbQBW/MDn/EwA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-core": "3.5.44",
|
||||
"@vue/shared": "3.5.44"
|
||||
"@vue/compiler-core": "3.5.45",
|
||||
"@vue/shared": "3.5.45"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-sfc": {
|
||||
"version": "3.5.44",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.44.tgz",
|
||||
"integrity": "sha512-dzHmQ4jXTpdr5FjIQUeykVakN/uzqFbUo9/C5ikBFg3a3PeM6uRxeczx1ZbXBML0/zJstEh3ygYipzR5Z7b2Pw==",
|
||||
"version": "3.5.45",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.45.tgz",
|
||||
"integrity": "sha512-MKFjb2UX0M/l/jhfzqMLrI8VM4pfvFKG3pqFZkSZFHRLtNld/O4RtUPZFWSwhro/14qP88UQEkWzHxAZAQ0tsw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.29.9",
|
||||
"@vue/compiler-core": "3.5.44",
|
||||
"@vue/compiler-dom": "3.5.44",
|
||||
"@vue/compiler-ssr": "3.5.44",
|
||||
"@vue/shared": "3.5.44",
|
||||
"@babel/parser": "^7.29.12",
|
||||
"@vue/compiler-core": "3.5.45",
|
||||
"@vue/compiler-dom": "3.5.45",
|
||||
"@vue/compiler-ssr": "3.5.45",
|
||||
"@vue/shared": "3.5.45",
|
||||
"estree-walker": "^2.0.2",
|
||||
"magic-string": "^0.30.21",
|
||||
"postcss": "^8.5.29",
|
||||
"postcss": "^8.5.32",
|
||||
"source-map-js": "^1.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/compiler-ssr": {
|
||||
"version": "3.5.44",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.44.tgz",
|
||||
"integrity": "sha512-xr5gb1JVHlfXJwSlRz1FeP6uxoazdzHuMTVLE7up+4Vrqxk219CvxLPxD9NXBt47yvZW7+p4DXfyp4O1fkByIA==",
|
||||
"version": "3.5.45",
|
||||
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.45.tgz",
|
||||
"integrity": "sha512-RF5sbZOfYz5AK00tOJUn2PwFXR2fS1u2HVzI8D9VF9rGAFxuGBqg2bB1kJ3ZHMprqSltXnT9MZE1IsqjSM8oew==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-dom": "3.5.44",
|
||||
"@vue/shared": "3.5.44"
|
||||
"@vue/compiler-dom": "3.5.45",
|
||||
"@vue/shared": "3.5.45"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/devtools-api": {
|
||||
@@ -1409,51 +1409,51 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/reactivity": {
|
||||
"version": "3.5.44",
|
||||
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.44.tgz",
|
||||
"integrity": "sha512-u+QJdKeBBEADkPdevsL+6E12QlYVfBD8Zcw5qjDQKtamI6l14KyqazJMobhCKelhWN5zpyKUiEDoTyHE93cqWw==",
|
||||
"version": "3.5.45",
|
||||
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.45.tgz",
|
||||
"integrity": "sha512-WqkyubNWpI4OYBOipSrjIssMdJO8K1i9Zts/Wm8Er10/0msOEwCyWWWvZnAI7WW3kQsTong6DJp8Cbb+vd4cPA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/shared": "3.5.44"
|
||||
"@vue/shared": "3.5.45"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/runtime-core": {
|
||||
"version": "3.5.44",
|
||||
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.44.tgz",
|
||||
"integrity": "sha512-uEa/ndwjhrrhnOfb2p+sZy6zeoamJOISqaLSJGk/8R6nABT1ZldpzcJoPzKj+zHVomVBPcmQYyC2r4LtvDV6CQ==",
|
||||
"version": "3.5.45",
|
||||
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.45.tgz",
|
||||
"integrity": "sha512-bzIO3+FABjpj85uIKSc+Qnj36/sxDNI3tcH9i6w6xKA1k6e0ejv0G0jMCfeJBvK3yGL5XbJ3DMZj+ClqyCHFYw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/reactivity": "3.5.44",
|
||||
"@vue/shared": "3.5.44"
|
||||
"@vue/reactivity": "3.5.45",
|
||||
"@vue/shared": "3.5.45"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/runtime-dom": {
|
||||
"version": "3.5.44",
|
||||
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.44.tgz",
|
||||
"integrity": "sha512-3fc4ARcXVhVBaJ3ujWiNZJARD6pkyRcwG+ZYhMzjKtKUp7MAY0HLwr7r3Smep3Li6ZaWT6ewdmx8XqdaD5oNZg==",
|
||||
"version": "3.5.45",
|
||||
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.45.tgz",
|
||||
"integrity": "sha512-ZvRTFMDgfqTDYWvJfoVpQTJx1RN5M6l7Pyd6wfdY2NaXzbPQVh9ezeQYFbNPP6bIcRVn2SqSSR25N/jSW69BFw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/reactivity": "3.5.44",
|
||||
"@vue/runtime-core": "3.5.44",
|
||||
"@vue/shared": "3.5.44",
|
||||
"@vue/reactivity": "3.5.45",
|
||||
"@vue/runtime-core": "3.5.45",
|
||||
"@vue/shared": "3.5.45",
|
||||
"csstype": "^3.2.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/server-renderer": {
|
||||
"version": "3.5.44",
|
||||
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.44.tgz",
|
||||
"integrity": "sha512-R4S1UoH4h5Frrauv8Z5XE5TxV9oBiUSgWIC4TyVK1FK+RocRnOLwFA5Xcmo2011RlgJp+AbZCnw6afrhlgRuUQ==",
|
||||
"version": "3.5.45",
|
||||
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.45.tgz",
|
||||
"integrity": "sha512-1fNXUHhhsWf4EVL4XixbGBU5mKdiIXJAB82feHRTyPPo6ZUEYWIJuEeUl3mVV6QDBp50HJOX4obLhxYXlrjrzA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-ssr": "3.5.44",
|
||||
"@vue/runtime-dom": "3.5.44",
|
||||
"@vue/shared": "3.5.44"
|
||||
"@vue/compiler-ssr": "3.5.45",
|
||||
"@vue/runtime-dom": "3.5.45",
|
||||
"@vue/shared": "3.5.45"
|
||||
}
|
||||
},
|
||||
"node_modules/@vue/shared": {
|
||||
"version": "3.5.44",
|
||||
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.44.tgz",
|
||||
"integrity": "sha512-H82XLH0DjmSOdbEwO15x3QTo1f5PWEtv237eLpYKc0mqLu+B8hnq16lFWmuBmNurkeiG3wr+oM1FhOll/YVFRg==",
|
||||
"version": "3.5.45",
|
||||
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.45.tgz",
|
||||
"integrity": "sha512-ue9fgHmVNPlP7iW3+cxoBX/Cnlw53dHlVSw0JKGY6z1lObg8pHoj928M2nzG4/yVsMZ3NaRZ2s2z61uC16NDwQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@vue/typescript-plugin": {
|
||||
@@ -6462,9 +6462,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.31",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.31.tgz",
|
||||
"integrity": "sha512-YUbWYCgErwnMAVkjUnYa+KlMBzGpHwiIt/DE7f0G33AuX2LH9UcTk6KgWxd3zRU+pN3u/C+Xl3EnMLM4Hea7Sg==",
|
||||
"version": "8.5.32",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.32.tgz",
|
||||
"integrity": "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
@@ -7802,16 +7802,16 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/vue": {
|
||||
"version": "3.5.44",
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.44.tgz",
|
||||
"integrity": "sha512-dvvmaOCG7lAMkJTPqPwWeGMsPS6DIsFsfZDUgBp9V6mHf9b3+/wyVwYR4Es+WV6uJC0FKRxp81Obcq0ZwUcGFQ==",
|
||||
"version": "3.5.45",
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.45.tgz",
|
||||
"integrity": "sha512-3cvsib8m9c0vB24+MDKsgcW4+Da4xaBl9Z/5Tbm2pmSIsRPxcil4cdXjXlVsmJ2g64XJo5h+IRd7rsdGT9pZaw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@vue/compiler-dom": "3.5.44",
|
||||
"@vue/compiler-sfc": "3.5.44",
|
||||
"@vue/runtime-dom": "3.5.44",
|
||||
"@vue/server-renderer": "3.5.44",
|
||||
"@vue/shared": "3.5.44"
|
||||
"@vue/compiler-dom": "3.5.45",
|
||||
"@vue/compiler-sfc": "3.5.45",
|
||||
"@vue/runtime-dom": "3.5.45",
|
||||
"@vue/server-renderer": "3.5.45",
|
||||
"@vue/shared": "3.5.45"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "*"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"qrcodejs": "^1.0.0",
|
||||
"simple-code-editor": "^2.0.9",
|
||||
"uuid": "^14.0.3",
|
||||
"vue": "^3.5.32",
|
||||
"vue": "^3.5.45",
|
||||
"vue-chartjs": "^5.3.4",
|
||||
"vue-router": "^5.4.0"
|
||||
},
|
||||
|
||||
@@ -101,6 +101,14 @@ export default {
|
||||
<samp>{{Peer.allowed_ip}}</samp>
|
||||
</small>
|
||||
</div>
|
||||
<div :class="{'d-flex gap-2 align-items-center' : dashboardStore.Configuration.Server.dashboard_peer_list_display === 'list'}">
|
||||
<small class="text-muted">
|
||||
<LocaleText t="Endpoint"></LocaleText>
|
||||
</small>
|
||||
<small class="d-block">
|
||||
<samp>{{Peer.endpoint && Peer.endpoint !== 'N/A' ? Peer.endpoint : '(none)'}}</samp>
|
||||
</small>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-1"
|
||||
:class="{'ms-auto': dashboardStore.Configuration.Server.dashboard_peer_list_display === 'list'}"
|
||||
>
|
||||
|
||||
@@ -88,6 +88,16 @@ defineEmits(['close'])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="word-break: break-all" class="col-12 col-lg-6">
|
||||
<div class="card rounded-3 bg-transparent h-100">
|
||||
<div class="card-body py-2 d-flex flex-column justify-content-center">
|
||||
<p class="mb-0 text-muted"><small>
|
||||
<LocaleText t="Endpoint"></LocaleText>
|
||||
</small></p>
|
||||
<samp>{{selectedPeer.endpoint && selectedPeer.endpoint !== 'N/A' ? selectedPeer.endpoint : '(none)'}}</samp>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="word-break: break-all" class="col-12 col-lg-6">
|
||||
<div class="card rounded-3 bg-transparent h-100">
|
||||
<div class="card-body py-2 d-flex flex-column justify-content-center">
|
||||
|
||||
@@ -191,6 +191,12 @@ const searchPeers = computed(() => {
|
||||
wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags || (!wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags && taggedPeers.value.includes(x.id))
|
||||
));
|
||||
|
||||
if (dashboardStore.Configuration.Server.dashboard_sort === "traffic"){
|
||||
return result.sort((a, b) => {
|
||||
return (b.total_data + b.cumu_data) - (a.total_data + a.cumu_data)
|
||||
}).slice(0, showPeersCount.value);
|
||||
}
|
||||
|
||||
if (dashboardStore.Configuration.Server.dashboard_sort === "restricted"){
|
||||
return result.sort((a, b) => {
|
||||
if ( a[dashboardStore.Configuration.Server.dashboard_sort]
|
||||
|
||||
@@ -24,6 +24,7 @@ export default {
|
||||
status: GetLocale("Status"),
|
||||
name: GetLocale("Name"),
|
||||
allowed_ip: GetLocale("Allowed IPs"),
|
||||
traffic: GetLocale("Total Usage"),
|
||||
restricted: GetLocale("Restricted")
|
||||
},
|
||||
interval: {
|
||||
|
||||
@@ -29,12 +29,8 @@ const requestToken = async (e) => {
|
||||
}
|
||||
|
||||
const code = ref("")
|
||||
const parseCode = () => {
|
||||
code.value = code.value.replace(/\D/i, "")
|
||||
code.value = code.value.slice(0, 6)
|
||||
}
|
||||
const codeReady = computed(() => {
|
||||
return /^[0-9]{6}$/.test(code.value)
|
||||
return code.value.trim().length > 0
|
||||
})
|
||||
const codeValidated = ref(false)
|
||||
const validateCode = async (e) => {
|
||||
@@ -42,13 +38,13 @@ const validateCode = async (e) => {
|
||||
loading.value = true
|
||||
let codeValidation = await axiosPost("/api/resetPassword/validateResetToken", {
|
||||
Email: email.value,
|
||||
Token: code.value
|
||||
Token: code.value.trim()
|
||||
})
|
||||
loading.value = false
|
||||
if (codeValidation.status){
|
||||
codeValidated.value = true
|
||||
}else{
|
||||
store.newNotification("Your verification code is either invalid or expired", "danger")
|
||||
store.newNotification("Your reset token is either invalid or expired", "danger")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +59,7 @@ const resetPassword = async (e) => {
|
||||
loading.value = true;
|
||||
let reset = await axiosPost("/api/resetPassword", {
|
||||
Email: email.value,
|
||||
Token: code.value,
|
||||
Token: code.value.trim(),
|
||||
Password: password.value,
|
||||
ConfirmPassword: confirmPassword.value
|
||||
})
|
||||
@@ -71,6 +67,8 @@ const resetPassword = async (e) => {
|
||||
store.newNotification("Password reset! Now you can sign in with your new password", "success")
|
||||
|
||||
await router.push('/signin')
|
||||
}else{
|
||||
store.newNotification(reset.message || "Password reset failed", "danger")
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -98,7 +96,7 @@ const resetPassword = async (e) => {
|
||||
autocomplete="email"
|
||||
autofocus
|
||||
class="form-control rounded-3 border-0" id="email" placeholder="email">
|
||||
<label for="email" class="d-flex">
|
||||
<label for="token" class="d-flex">
|
||||
<i class="bi bi-person-circle me-2"></i>
|
||||
Email
|
||||
</label>
|
||||
@@ -122,7 +120,7 @@ const resetPassword = async (e) => {
|
||||
</a>
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Almost there</h1>
|
||||
<p class="text-muted">Enter the code you received below to retrieve a reset your password</p>
|
||||
<p class="text-muted">Enter the reset token you received below to reset your password</p>
|
||||
<p class="text-muted" v-if="resendCountdown > 0">Didn't get the code? Maybe check your Spam/Junk mailbox. You can get another code in {{ resendCountdown }} seconds.</p>
|
||||
<a role="button"
|
||||
:class="{disabled: loading}"
|
||||
@@ -131,17 +129,17 @@ const resetPassword = async (e) => {
|
||||
<form class="mt-4 d-flex flex-column gap-3" @submit="e => validateCode(e)">
|
||||
<div class="form-floating">
|
||||
<input type="text"
|
||||
inputmode="numeric"
|
||||
required
|
||||
:disabled="loading"
|
||||
v-model="code"
|
||||
@keyup="parseCode()"
|
||||
autocomplete="one-time-code"
|
||||
autocomplete="off"
|
||||
autocapitalize="off"
|
||||
spellcheck="false"
|
||||
autofocus
|
||||
class="form-control rounded-3 border-0" id="token" placeholder="token">
|
||||
<label for="email" class="d-flex">
|
||||
<label for="token" class="d-flex">
|
||||
<i class="bi bi-person-circle me-2"></i>
|
||||
6 Digits Verification Code
|
||||
Password Reset Token
|
||||
</label>
|
||||
</div>
|
||||
<button
|
||||
|
||||
+45
-9
@@ -393,12 +393,12 @@ _checkNode(){
|
||||
then
|
||||
printf "[WGDashboard] %s Node.js and npm are still not installed, halting script now.\n" "$heavy_crossmark"
|
||||
printf "%s\n" "$helpMsg"
|
||||
kill $TOP_PID
|
||||
return 1
|
||||
elif ! _isNodeVersionSupported
|
||||
then
|
||||
printf "[WGDashboard] %s Found Node.js %s, but the frontend requires Node.js 20.19+ or 22.12+. Halting install now.\n" "$heavy_crossmark" "$(node --version)"
|
||||
printf "%s\n" "$helpMsg"
|
||||
kill $TOP_PID
|
||||
return 1
|
||||
else
|
||||
printf "[WGDashboard] %s Node.js %s and npm %s are installed\n" "$heavy_checkmark" "$(node --version)" "$(npm --version)"
|
||||
fi
|
||||
@@ -406,19 +406,50 @@ _checkNode(){
|
||||
|
||||
_compileFrontend(){
|
||||
_logSection "Compiling Frontend"
|
||||
_checkNode
|
||||
if ! _checkNode; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local dir
|
||||
for dir in "${frontend_dirs[@]}"; do
|
||||
local staging_root live_dir backup_dir dir output_dir index
|
||||
local frontend_output_dirs=("WGDashboardAdmin" "WGDashboardClient")
|
||||
staging_root=$(mktemp -d "$PWD/static/.dist-staging.XXXXXX") || return 1
|
||||
live_dir="$PWD/static/dist"
|
||||
backup_dir="${staging_root}.previous"
|
||||
|
||||
for index in "${!frontend_dirs[@]}"; do
|
||||
dir="${frontend_dirs[$index]}"
|
||||
output_dir="$staging_root/${frontend_output_dirs[$index]}"
|
||||
printf "[WGDashboard] %s Compiling frontend in %s\n" "$install" "$dir"
|
||||
if ! ( cd "$dir" && npm ci && npm run build ) &>> ./log/install.txt
|
||||
if ! ( cd "$dir" && npm ci && npm run build -- --outDir "$output_dir" --emptyOutDir ) &>> ./log/install.txt
|
||||
then
|
||||
printf "[WGDashboard] %s Failed to compile frontend in %s, halting script now.\n" "$heavy_crossmark" "$dir"
|
||||
printf "%s\n" "$helpMsg"
|
||||
kill $TOP_PID
|
||||
rm -rf "$staging_root"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ! -f "$staging_root/WGDashboardAdmin/index.html" || ! -f "$staging_root/WGDashboardClient/client.html" ]]; then
|
||||
printf "[WGDashboard] %s Frontend build did not produce the expected entry files.\n" "$heavy_crossmark"
|
||||
rm -rf "$staging_root"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -e "$live_dir" ]] && ! mv "$live_dir" "$backup_dir"; then
|
||||
printf "[WGDashboard] %s Could not preserve the current frontend bundle.\n" "$heavy_crossmark"
|
||||
rm -rf "$staging_root"
|
||||
return 1
|
||||
fi
|
||||
if ! mv "$staging_root" "$live_dir"; then
|
||||
printf "[WGDashboard] %s Could not install the new frontend bundle.\n" "$heavy_crossmark"
|
||||
if [[ -e "$backup_dir" ]]; then
|
||||
mv "$backup_dir" "$live_dir"
|
||||
fi
|
||||
rm -rf "$staging_root"
|
||||
return 1
|
||||
fi
|
||||
rm -rf "$backup_dir"
|
||||
|
||||
printf "[WGDashboard] %s Frontend is compiled\n" "$heavy_checkmark"
|
||||
}
|
||||
|
||||
@@ -456,7 +487,9 @@ install_wgd(){
|
||||
_installPythonVenv
|
||||
_installPythonPip
|
||||
_checkWireguard
|
||||
_compileFrontend
|
||||
if ! _compileFrontend; then
|
||||
return 1
|
||||
fi
|
||||
sudo chmod -R 755 /etc/wireguard/
|
||||
|
||||
_check_and_set_venv
|
||||
@@ -601,7 +634,10 @@ update_wgd() {
|
||||
printf "[WGDashboard] Downloading %s from GitHub..." "$new_ver"
|
||||
{ date; git stash; git pull https://github.com/WGDashboard/WGDashboard.git $new_ver --force; } >> ./log/update.txt
|
||||
chmod +x ./wgd.sh
|
||||
sudo ./wgd.sh install
|
||||
if ! sudo ./wgd.sh install; then
|
||||
printf "[WGDashboard] %s Update installation failed. Check ./log/install.txt; the previous frontend bundle was preserved when possible.\n" "$heavy_crossmark"
|
||||
return 1
|
||||
fi
|
||||
printf "[WGDashboard] Update completed!\n"
|
||||
rm wgd.sh.old
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user