Compare commits
No commits in common. "846e9a7aa5492c7fd6345c9935d7f2502cac3938" and "6a1429614bc77eed364b849d1cd1d02aca174137" have entirely different histories.
846e9a7aa5
...
6a1429614b
@ -19,31 +19,16 @@ import ListSecrets from "./components/ListSecrets.vue";
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-dialog
|
<el-dialog v-model="creationDialog" title="Add a new TOTP secret" width="80vw">
|
||||||
v-model="creationDialog"
|
|
||||||
title="Add a new TOTP secret"
|
|
||||||
destroy-on-close
|
|
||||||
width="80vw"
|
|
||||||
>
|
|
||||||
<CreateSecret @close="secretSaved" />
|
<CreateSecret @close="secretSaved" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<el-dialog
|
<el-dialog v-model="editDialog" title="Edit TOTP secret" width="80vw">
|
||||||
v-model="editDialog"
|
|
||||||
title="Edit TOTP secret"
|
|
||||||
destroy-on-close
|
|
||||||
width="80vw"
|
|
||||||
>
|
|
||||||
<CreateSecret :editSecret="editingSecret" @close="secretSaved" />
|
<CreateSecret :editSecret="editingSecret" @close="secretSaved" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<el-dialog
|
<el-dialog v-model="importDialog" title="Import TOTP secrets" width="80vw">
|
||||||
v-model="importDialog"
|
<ImportSecrets />
|
||||||
title="Import TOTP secrets"
|
|
||||||
destroy-on-close
|
|
||||||
width="80vw"
|
|
||||||
>
|
|
||||||
<ImportSecrets @close="secretsImported" />
|
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -95,11 +80,6 @@ export default {
|
|||||||
this.listUpdated += 1;
|
this.listUpdated += 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
secretsImported() {
|
|
||||||
this.importDialog = false;
|
|
||||||
this.listUpdated += 1;
|
|
||||||
},
|
|
||||||
|
|
||||||
async validateToken() {
|
async validateToken() {
|
||||||
const url = `${this.apiBaseUrl}/validate-token`;
|
const url = `${this.apiBaseUrl}/validate-token`;
|
||||||
const token = sessionStorage.getItem("token");
|
const token = sessionStorage.getItem("token");
|
||||||
|
@ -42,15 +42,6 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
>Save & Close</el-button
|
>Save & Close</el-button
|
||||||
>
|
>
|
||||||
<el-button
|
|
||||||
type="danger"
|
|
||||||
@click="
|
|
||||||
deleteSecret();
|
|
||||||
closeDialog();
|
|
||||||
"
|
|
||||||
v-if="this.method === 'PUT'"
|
|
||||||
>Delete</el-button
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -96,7 +87,7 @@ export default {
|
|||||||
},
|
},
|
||||||
body: JSON.stringify(bodyData),
|
body: JSON.stringify(bodyData),
|
||||||
};
|
};
|
||||||
// console.log(requestOptions);
|
console.log(requestOptions);
|
||||||
await fetch(url, requestOptions)
|
await fetch(url, requestOptions)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => console.log(data));
|
.then((data) => console.log(data));
|
||||||
@ -109,25 +100,6 @@ export default {
|
|||||||
(this.form.secret = "");
|
(this.form.secret = "");
|
||||||
this.$emit("close", true);
|
this.$emit("close", true);
|
||||||
},
|
},
|
||||||
|
|
||||||
async deleteSecret() {
|
|
||||||
const url = `${this.apiBaseUrl}/secret`;
|
|
||||||
const token = sessionStorage.getItem("token");
|
|
||||||
const bodyData = { data: btoa(JSON.stringify(this.form)) };
|
|
||||||
bodyData["id"] = this.id;
|
|
||||||
const requestOptions = {
|
|
||||||
method: "DELETE",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
},
|
|
||||||
body: JSON.stringify(bodyData),
|
|
||||||
};
|
|
||||||
// console.log(requestOptions);
|
|
||||||
await fetch(url, requestOptions)
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((data) => console.log(data));
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
|
@ -59,13 +59,13 @@ export default {
|
|||||||
var label = decodeURIComponent(url.pathname.slice(1)); // Remove the leading '/'
|
var label = decodeURIComponent(url.pathname.slice(1)); // Remove the leading '/'
|
||||||
const type = label.slice(1, -1).split("/")[0];
|
const type = label.slice(1, -1).split("/")[0];
|
||||||
label = label.slice(6);
|
label = label.slice(6);
|
||||||
let username, issuerFromLabel;
|
let accountName, issuerFromLabel;
|
||||||
const labelParts = label.split(":");
|
const labelParts = label.split(":");
|
||||||
if (labelParts.length === 2) {
|
if (labelParts.length === 2) {
|
||||||
issuerFromLabel = labelParts[0];
|
issuerFromLabel = labelParts[0];
|
||||||
username = labelParts[1];
|
accountName = labelParts[1];
|
||||||
} else {
|
} else {
|
||||||
username = label;
|
accountName = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = {};
|
const params = {};
|
||||||
@ -86,7 +86,7 @@ export default {
|
|||||||
scheme,
|
scheme,
|
||||||
type,
|
type,
|
||||||
label,
|
label,
|
||||||
username,
|
accountName,
|
||||||
issuer,
|
issuer,
|
||||||
secret,
|
secret,
|
||||||
algorithm,
|
algorithm,
|
||||||
@ -121,7 +121,6 @@ export default {
|
|||||||
for (var i = 0; i < this.parsedTokens.length; i++) {
|
for (var i = 0; i < this.parsedTokens.length; i++) {
|
||||||
await this.createSecret(this.parsedTokens[i]);
|
await this.createSecret(this.parsedTokens[i]);
|
||||||
}
|
}
|
||||||
this.$emit("close", true);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
8
main.py
8
main.py
@ -135,14 +135,6 @@ async def update_secret(secret: Secret, current_user: dict = Depends(get_current
|
|||||||
return token
|
return token
|
||||||
|
|
||||||
|
|
||||||
@app.delete('/secret')
|
|
||||||
async def delete_secret(secret: Secret, current_user: dict = Depends(get_current_user)):
|
|
||||||
"""Deletes the secret with the given id"""
|
|
||||||
secret.user_id = current_user['id']
|
|
||||||
# print(secret.model_dump())
|
|
||||||
user_id, secret_id = queries.DELETE_SECRET(secret.model_dump())
|
|
||||||
|
|
||||||
|
|
||||||
@app.get('/secret')
|
@app.get('/secret')
|
||||||
async def list_secret(current_user: dict = Depends(get_current_user)):
|
async def list_secret(current_user: dict = Depends(get_current_user)):
|
||||||
"""Returns the encrypted secrets of the user."""
|
"""Returns the encrypted secrets of the user."""
|
||||||
|
13
queries.py
13
queries.py
@ -143,19 +143,6 @@ UPDATE_SECRET = DbQuery(
|
|||||||
rows='single'
|
rows='single'
|
||||||
)
|
)
|
||||||
|
|
||||||
DELETE_SECRET = DbQuery(
|
|
||||||
"""
|
|
||||||
DELETE from secrets
|
|
||||||
WHERE
|
|
||||||
user_id = :user_id
|
|
||||||
and id = :id
|
|
||||||
RETURNING user_id, id
|
|
||||||
""",
|
|
||||||
type='write',
|
|
||||||
returns=True,
|
|
||||||
rows='single'
|
|
||||||
)
|
|
||||||
|
|
||||||
GET_SECRETS = DbQuery(
|
GET_SECRETS = DbQuery(
|
||||||
"""
|
"""
|
||||||
SELECT *
|
SELECT *
|
||||||
|
Loading…
Reference in New Issue
Block a user