Skip to content

Commit

Permalink
🔒 Remove JWT. (#154)
Browse files Browse the repository at this point in the history
Signed-off-by: zhanghengxin <ezreal.zhang@icewhale.org>
  • Loading branch information
zhanghengxin authored May 29, 2023
1 parent 81656b7 commit 0f19d87
Showing 1 changed file with 48 additions and 75 deletions.
123 changes: 48 additions & 75 deletions main/src/components/Storage/StorageItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
</h4>

<p class="has-text-left is-size-7 has-text-grey-light ">{{ $t('Single Drive Storage') }}, <span
class="is-uppercase">{{ item.fsType }}</span>
class="is-uppercase">{{ item.fsType }}</span>
<b-tooltip :label="$t('CasaOS reserves 1% of file space when creating storage in EXT4 format.')"
append-to-body>
<b-icon class="mr-2 " icon="help-circle-outline" size="is-small"></b-icon>
</b-tooltip>
</p>
<p class="has-text-left is-size-7 ">{{
$t("Available Total", {
name: item.diskName,
avl: renderSize(item.availSize),
total: renderSize(item.size)
})
$t("Available Total", {
name: item.diskName,
avl: renderSize(item.availSize),
total: renderSize(item.size)
})
}}</p>
</div>

Expand All @@ -60,10 +60,8 @@
</template>

<script>
import {mixin} from '@/mixins/mixin';
import delay from 'lodash/delay';
import jwt_decode from "jwt-decode";
import MD5 from 'md5-es';
import {mixin} from '@/mixins/mixin';
import delay from 'lodash/delay';

export default {
name: "drive-item",
Expand Down Expand Up @@ -101,46 +99,33 @@ export default {
path: path,
password: value
}
// get token from the local storage
const token = localStorage.getItem('access_token')
// decode the token
const tokenJson = jwt_decode(token)
if (MD5.hash(value) === tokenJson.password) {
this.$api.disks.umount(data).then((res) => {
if (res.data.success != 200) {
this.isRemoving = false;
this.$buefy.toast.open({
duration: 3000,
message: res.data.message,
type: 'is-danger'
})
console.error(res);
} else {
this.isRemoving = false;
let _this = this
delay(() => {
_this.isRemoving = false;
_this.$emit('getDiskList');
}, 1000);
}
}).catch(e => {

this.$api.disks.umount(data).then((res) => {
if (res.data.success != 200) {
this.isRemoving = false;
this.$buefy.toast.open({
duration: 3000,
message: e.response.data.message,
message: res.data.message,
type: 'is-danger'
})
console.error(e)
console.error(res);
} else {
this.isRemoving = false;
let _this = this
delay(() => {
_this.isRemoving = false;
_this.$emit('getDiskList');
}, 1000);
}
}).catch(e => {
this.isRemoving = false;
this.$buefy.toast.open({
duration: 3000,
message: e.response.data.message,
type: 'is-danger'
})
return
}
this.isRemoving = false;
this.$buefy.toast.open({
duration: 3000,
message: this.$t("Password is incorrect"),
type: 'is-danger'
console.error(e)
})
console.error("Password is incorrect")
}
})
},
Expand All @@ -166,45 +151,33 @@ export default {
volume: mount_point,
password: value
}
// get token from the local storage
const token = localStorage.getItem('access_token')
// decode the token
const tokenJson = jwt_decode(token)
if (MD5.hash(value) === tokenJson.password) {
this.$api.storage.format(data).then((res) => {
if (res.data.success != 200) {
this.isFormating = false;
this.$buefy.toast.open({
duration: 3000,
message: res.data.message,
type: 'is-danger'
})
console.error(res)
} else {
let _this = this
delay(() => {
_this.isFormating = false;
_this.$emit('getDiskList');
}, 1000);
}
}).catch(e => {

this.$api.storage.format(data).then((res) => {
if (res.data.success != 200) {
this.isFormating = false;
this.$buefy.toast.open({
duration: 3000,
message: e.response.data.message,
message: res.data.message,
type: 'is-danger'
})
console.error(e)
console.error(res)
} else {
let _this = this
delay(() => {
_this.isFormating = false;
_this.$emit('getDiskList');
}, 1000);
}
}).catch(e => {
this.isFormating = false;
this.$buefy.toast.open({
duration: 3000,
message: e.response.data.message,
type: 'is-danger'
})
return
}
this.isFormating = false;
this.$buefy.toast.open({
duration: 3000,
message: this.$t("Password is incorrect"),
type: 'is-danger'
console.error(e)
})
console.error("Password is incorrect")

}
})
},
Expand Down

0 comments on commit 0f19d87

Please sign in to comment.