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">
|
2021-03-18 18:09:04 +00:00
|
|
|
<h1 class="create-pass__title">Objects</h1>
|
|
|
|
<div class="create-pass__container">
|
|
|
|
<GeneratePassphrase
|
|
|
|
:is-loading="isLoading"
|
|
|
|
:on-button-click="onNextClick"
|
|
|
|
:set-parent-passphrase="setPassphrase"
|
|
|
|
/>
|
|
|
|
</div>
|
2021-02-24 22:53:57 +00:00
|
|
|
</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-03-18 18:09:04 +00:00
|
|
|
this.$router.push({
|
|
|
|
name: RouteConfig.BucketsManagement.name,
|
|
|
|
params: {
|
|
|
|
passphrase: this.passphrase,
|
|
|
|
},
|
|
|
|
});
|
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-03-18 18:09:04 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
&__title {
|
|
|
|
font-family: 'font_medium', sans-serif;
|
|
|
|
font-style: normal;
|
|
|
|
font-weight: bold;
|
|
|
|
font-size: 18px;
|
|
|
|
line-height: 26px;
|
|
|
|
color: #232b34;
|
|
|
|
margin: 0;
|
|
|
|
width: 100%;
|
|
|
|
text-align: left;
|
|
|
|
}
|
|
|
|
|
|
|
|
&__container {
|
|
|
|
margin-top: 100px;
|
|
|
|
}
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
</style>
|