Skip to content

Commit

Permalink
cosmetic change
Browse files Browse the repository at this point in the history
  • Loading branch information
so5 committed Oct 25, 2024
1 parent 88d7a84 commit a61ed50
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 165 deletions.
2 changes: 1 addition & 1 deletion client/src/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export default {
removeProjectMessage() {
return this.removeFromList ? "remove following projects from list" : "remove following project files";
},
hasError(){
hasError() {
return this.required(this.newProjectName) !== true;
}
},
Expand Down
14 changes: 7 additions & 7 deletions client/src/components/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ export default {
password: null,
loading: false,
showPassword: false
}},
};
},
methods: {
async onSubmit () {
if (!this.form) return
this.loading = true
async onSubmit() {
if (!this.form) return;
this.loading = true;
const form = document.createElement("form");
form.setAttribute("action", "./login");
form.setAttribute("method", "post");
Expand All @@ -103,7 +104,6 @@ export default {
form.submit();
},
required
},
}
}
};
</script>

33 changes: 16 additions & 17 deletions client/src/components/Remotehost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -244,35 +244,34 @@ export default {
const target = this.hosts[index];
target.loading = true;
SIO.emitGlobal("tryToConnect", this.hosts[index], (rt)=>{
debug("connection test result:",rt);
target.loading= false
debug("connection test result:", rt);
target.loading = false;
if(rt === "canceled"){
if (rt === "canceled") {
target.connectionStatus = "test";
target.icon = "mdi-lan-pending";
target.testResult="background";
}else if (rt === "success"){
target.testResult = "background";
} else if (rt === "success") {
target.connectionStatus = "OK";
target.icon = "mdi-lan-connect";
target.testResult="success";
}else{
target.testResult = "success";
} else {
target.connectionStatus = "failed";
target.icon = "mdi-lan-disconnect";
target.testResult="error";
target.testResult = "error";
if(rt.code === "HostKeyError"){
if(rt.lineNumber && rt.host){
this.snackbarMessage=`remote host identification of ${rt.host} is different from the one on line ${rt.lineNumber} of ~/.ssh/known_hosts`
}else{
this.snackbarMessage="remote host identification is different from the one stored in ~/.ssh/known_hosts"
if (rt.code === "HostKeyError") {
if (rt.lineNumber && rt.host) {
this.snackbarMessage = `remote host identification of ${rt.host} is different from the one on line ${rt.lineNumber} of ~/.ssh/known_hosts`;
} else {
this.snackbarMessage = "remote host identification is different from the one stored in ~/.ssh/known_hosts";
}
this.openSnackbar=true;
this.openSnackbar = true;
}
}
this.pwDialog=false
this.testing=null;
this.pwDialog = false;
this.testing = null;
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/rapid/tabEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export default {
const content = document.getValue();
if (file.content === content) {
console.log("do not call 'saveFile' API because file is not changed. index=", index);
return
return;
}
SIO.emitGlobal("saveFile", this.projectRootDir, file.filename, file.dirname, content, (rt)=>{
if (!rt) {
Expand Down Expand Up @@ -349,7 +349,7 @@ export default {
this.commitSelectedFile(null);
}
},
changeTab (argIndex) {
changeTab(argIndex) {
if (argIndex >= this.files.length) {
//just ignored
return;
Expand Down
28 changes: 14 additions & 14 deletions client/src/components/rapid/unsavedFilesDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,39 +43,39 @@
</template>
<script>
export default {
props:{
props: {
unsavedFiles: {
type: Array,
required: true
},
dialog: {
type: Boolean,
required: true
},
}
},
data () {
data() {
return {
headers: [
{ title: "filename", key: "name" },
],
{ title: "filename", key: "name" }
]
};
},
computed:{
show(){
computed: {
show() {
return this.dialog;
},
items(){
items() {
return this.unsavedFiles;
}
},
methods: {
closeDialog () {
this.$emit("closed","cancel");
},
discardChanges () {
this.$emit("closed","discard");
closeDialog() {
this.$emit("closed", "cancel");
},
},
discardChanges() {
this.$emit("closed", "discard");
}
}
};
</script>
<style scoped>
Expand Down
4 changes: 2 additions & 2 deletions client/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* See License in the project root for the license information.
*/
import { createRouter, createMemoryHistory } from "vue-router";
import Graph from "../views/graph.vue";
import List from "../views/taskList.vue";
import Graph from "../views/graph.vue";
import List from "../views/taskList.vue";
import Editor from "../views/rapid.vue";

const routes = [
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default [
}
},
{
files: ["server/app/**/*.js"],
files: ["server/app/**/*.js", "server/bin/*.js"],
plugins: {
node
},
Expand Down
84 changes: 42 additions & 42 deletions server/app/core/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@
* See License in the project root for the license information.
*/
"use strict";
const path=require("path");
const path = require("path");
const crypto = require("crypto");
const { promisify } = require("util");
const { Database } = require("sqlite3");
const { open } = require("sqlite")
const {userDBFilename,userDBDir} = require("../db/db.js");
const { open } = require("sqlite");
const { userDBFilename, userDBDir } = require("../db/db.js");
const { getLogger } = require("../logSettings");
const logger = getLogger();

let db
let initialized=false;
let db;
let initialized = false;

/**
* open database and create tabel if not exists
*/
async function initialize(){
async function initialize() {
//open the database
db = await open({
filename: path.resolve(userDBDir, userDBFilename),
driver: Database
})
});
await db.exec("CREATE TABLE IF NOT EXISTS users ( \
id INT PRIMARY KEY, \
username TEXT UNIQUE, \
hashed_password BLOB, \
salt BLOB \
)")
initialized=true
return db
)");
initialized = true;
return db;
}

/**
Expand All @@ -41,7 +41,7 @@ async function initialize(){
* @param {string} salt - salt string
* @return {string} - hashed password
*/
async function getHashedPassword(password, salt){
async function getHashedPassword(password, salt) {
return promisify(crypto.pbkdf2)(password, salt, 210000, 32, "sha512");
}

Expand All @@ -50,17 +50,17 @@ async function getHashedPassword(password, salt){
* @param {string} username - new user's name
* @param {string} password - new user's password
*/
async function addUser(username, password){
if(!initialized){
await initialize()
async function addUser(username, password) {
if (!initialized) {
await initialize();
}
if(await getUserData(username) !== null){
if (await getUserData(username) !== null) {
const err = new Error("user already exists");
err.username=username
throw err
err.username = username;
throw err;
}
const id=crypto.randomUUID();
const salt=crypto.randomBytes(16);
const id = crypto.randomUUID();
const salt = crypto.randomBytes(16);
const hashedPassword = await getHashedPassword(password, salt);
await db.run("INSERT OR IGNORE INTO users (id, username, hashed_password, salt) VALUES (?, ?, ?, ?)", id, username, hashedPassword, salt);
}
Expand All @@ -70,10 +70,10 @@ async function addUser(username, password){
* @param {string} username - username to be queried
* @return {Object} - userdata which inclueds id, username, hashed_passowrd, salt
*/
async function getUserData(username){
async function getUserData(username) {
const row = await db.get("SELECT * FROM users WHERE username = ?", username);
if(!row){
return null
if (!row) {
return null;
}
return username === row.username ? row : null;
}
Expand All @@ -84,37 +84,37 @@ async function getUserData(username){
* @param {string} pasword - user's password in plain text
* @return {Boolean|Object} - return user data if valid pair, or false if invalid
*/
async function isValidUser(username, password){
if(!initialized){
await initialize()
async function isValidUser(username, password) {
if (!initialized) {
await initialize();
}
//check valid user
const row = await getUserData(username);
if(row === null){
logger.trace(`user: ${username} not found`)
return false
if (row === null) {
logger.trace(`user: ${username} not found`);
return false;
}
const hashedPassword = await getHashedPassword(password, row.salt);

//password verification
if(! crypto.timingSafeEqual(row.hashed_password, hashedPassword)){
logger.trace("wrong password")
return false
if (!crypto.timingSafeEqual(row.hashed_password, hashedPassword)) {
logger.trace("wrong password");
return false;
}
return row
return row;
}

/**
* list all user in DB
* @return {string[]} - array of usernames
*/
async function listUser(){
if(!initialized){
await initialize()
async function listUser() {
if (!initialized) {
await initialize();
}
const tmp = await db.all("SELECT username FROM users");
return tmp.map((e)=>{
return e.username
return e.username;
});
}

Expand All @@ -123,17 +123,17 @@ async function listUser(){
* @param {string} username - user's name
* @return {Boolean} - false if user does not exist in DB
*/
async function delUser(username){
if(!initialized){
await initialize()
async function delUser(username) {
if (!initialized) {
await initialize();
}
return db.run(`DELETE FROM users WHERE username = '${username}'`)
return db.run(`DELETE FROM users WHERE username = '${username}'`);
}

module.exports={
module.exports = {
initialize,
addUser,
isValidUser,
listUser,
delUser
}
};
2 changes: 1 addition & 1 deletion server/app/core/projectFilesOperator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ async function createNewComponent(projectRootDir, parentDir, type, pos) {
await writeComponentJson(projectRootDir, absDirName, newComponent);
await updateComponentPath(projectRootDir, newComponent.ID, absDirName);
if (type === "PS") {
const PSConfigFilename=path.resolve(absDirName, defaultPSconfigFilename)
const PSConfigFilename = path.resolve(absDirName, defaultPSconfigFilename);
await writeJsonWrapper(PSConfigFilename, { version: 2, targetFiles: [], params: [], scatter: [], gather: [] });
await gitAdd(projectRootDir, PSConfigFilename);
}
Expand Down
2 changes: 1 addition & 1 deletion server/app/handlers/workflowEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {
replaceWebhook,
getProjectJson
} = require("../core/projectFilesOperator.js");
const { getComponentDir } = require("../core/componentJsonIO.js");
const { getComponentDir } = require("../core/componentJsonIO.js");
const { sendWorkflow, sendProjectJson, sendComponentTree } = require("./senders.js");
const { convertPathSep } = require("../core/pathUtils");
const { updateComponent, updateComponentPos } = require("../core/updateComponent.js");
Expand Down
Loading

0 comments on commit a61ed50

Please sign in to comment.