2021-02-22 16:46:07 +00:00
|
|
|
// Copyright (C) 2021 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2021-02-24 22:53:57 +00:00
|
|
|
<template>
|
|
|
|
<div class="create-pass">
|
|
|
|
<GeneratePassphrase
|
|
|
|
:is-loading="isLoading"
|
|
|
|
:on-button-click="onNextClick"
|
|
|
|
:set-parent-passphrase="setPassphrase"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-02-22 16:46:07 +00:00
|
|
|
<script lang="ts">
|
2021-02-24 23:56:25 +00:00
|
|
|
import pbkdf2 from 'pbkdf2';
|
2021-02-22 16:46:07 +00:00
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
|
|
|
|
2021-02-24 22:53:57 +00:00
|
|
|
import GeneratePassphrase from '@/components/common/GeneratePassphrase.vue';
|
|
|
|
|
2021-02-24 23:56:25 +00:00
|
|
|
import { RouteConfig } from '@/router';
|
|
|
|
import { LocalData } from '@/utils/localData';
|
|
|
|
|
2021-02-24 22:53:57 +00:00
|
|
|
@Component({
|
|
|
|
components: {
|
|
|
|
GeneratePassphrase,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class CreatePassphrase extends Vue {
|
|
|
|
private isLoading: boolean = false;
|
|
|
|
|
|
|
|
public passphrase: string = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets passphrase from child component.
|
|
|
|
*/
|
|
|
|
public setPassphrase(passphrase: string): void {
|
|
|
|
this.passphrase = passphrase;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds on next button click logic.
|
|
|
|
*/
|
2021-02-25 01:05:45 +00:00
|
|
|
public onNextClick(): void {
|
2021-02-24 22:53:57 +00:00
|
|
|
if (this.isLoading) return;
|
|
|
|
|
|
|
|
this.isLoading = true;
|
2021-02-24 23:56:25 +00:00
|
|
|
|
|
|
|
const SALT = 'storj-unique-salt';
|
|
|
|
pbkdf2.pbkdf2(this.passphrase, SALT, 1, 64, (error, key) => {
|
|
|
|
if (error) return this.$notify.error(error.message);
|
|
|
|
|
|
|
|
LocalData.setUserIDPassSalt(this.$store.getters.user.id, key.toString('hex'), SALT);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.isLoading = false;
|
|
|
|
|
2021-02-25 01:05:45 +00:00
|
|
|
this.$router.push(RouteConfig.UploadFile.path);
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-22 16:46:07 +00:00
|
|
|
</script>
|
2021-02-24 22:53:57 +00:00
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.create-pass {
|
2021-02-25 01:05:45 +00:00
|
|
|
margin-top: 100px;
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
</style>
|