|
| 1 | +<script> |
| 2 | + import { getContext, onDestroy, onMount} from 'svelte'; |
| 3 | + //Components |
| 4 | + import { Components, LeftSideFullPage } from '../Router.svelte' |
| 5 | + import NavLogo from '../nav/NavLogo.svelte'; |
| 6 | + import { fade } from 'svelte/transition'; |
| 7 | +
|
| 8 | + //Stores |
| 9 | + import { SettingsStore } from '../../js/stores/stores.js'; |
| 10 | +
|
| 11 | + //Utils |
| 12 | + import { hashStringValue } from '../../js/utils.js' |
| 13 | +
|
| 14 | + //Context |
| 15 | + const { switchPage, appHome} = getContext('app_functions'); |
| 16 | +
|
| 17 | + const { Button, InputBox } = Components; |
| 18 | +
|
| 19 | + let oldPwd; |
| 20 | +
|
| 21 | + let password; |
| 22 | + let vaultExist = false; |
| 23 | + let step = 1; |
| 24 | + let repairSuccess = false; |
| 25 | +
|
| 26 | + onMount(() => { |
| 27 | + chrome.runtime.sendMessage({type: 'isVaultCreated'}, (ok) => { |
| 28 | + vaultExist = ok; |
| 29 | + }) |
| 30 | + }); |
| 31 | +
|
| 32 | +
|
| 33 | + onDestroy(()=> password = "") |
| 34 | +
|
| 35 | + const repair = () => { |
| 36 | + chrome.runtime.sendMessage({ |
| 37 | + type: "repairVault", |
| 38 | + data: hashStringValue(oldPwd.value), |
| 39 | + }, (success) => { |
| 40 | + if (!success || chrome.runtime.lastError) { |
| 41 | + repairSuccess = false |
| 42 | + } else { |
| 43 | + repairSuccess = true |
| 44 | + } |
| 45 | + step = 2 |
| 46 | + }); |
| 47 | + } |
| 48 | + |
| 49 | +</script> |
| 50 | + |
| 51 | +<style> |
| 52 | +.layout{ |
| 53 | + display: flex; |
| 54 | + flex-direction: column; |
| 55 | + flex-grow: 1; |
| 56 | +} |
| 57 | +
|
| 58 | +.content{ |
| 59 | + flex-grow: 1; |
| 60 | + display: flex; |
| 61 | +} |
| 62 | +
|
| 63 | +.header{ |
| 64 | + display: flex; |
| 65 | + flex-direction: row; |
| 66 | + position: absolute; |
| 67 | + left: 0%; |
| 68 | + right: 0%; |
| 69 | + top: 0%; |
| 70 | + bottom: 0%; |
| 71 | + right: 0; |
| 72 | + height: 97px; |
| 73 | + border-bottom: 1px solid var(--divider-light); |
| 74 | +} |
| 75 | +.alignc { |
| 76 | + align-items: center; |
| 77 | +} |
| 78 | +</style> |
| 79 | + |
| 80 | +<div class="layout"> |
| 81 | + <div class="header"> |
| 82 | + <NavLogo /> |
| 83 | + </div> |
| 84 | + <div class="content"> |
| 85 | + <LeftSideFullPage title={`Repair Vault`}> |
| 86 | + <div slot="body"> |
| 87 | + <div class="text-body1 weight-400 desc"> |
| 88 | + This process will allow you to repair your vault if you have changed your password in version 2.5.0 |
| 89 | + </div> |
| 90 | + </div> |
| 91 | + <div class="flex-row flow-page flex-just-center" in:fade="{{delay: 0, duration: 200}}" slot="content"> |
| 92 | + <div class="flex-column"> |
| 93 | + {#if step === 1} |
| 94 | + <h6 class="text-primary text-center">Repair Vault</h6> |
| 95 | + <div class="flex-column flow-buttons"> |
| 96 | + {#if vaultExist} |
| 97 | + <InputBox |
| 98 | + id="oldPwd" |
| 99 | + bind:thisInput={oldPwd} |
| 100 | + label={"Old Password"} |
| 101 | + placeholder={"The password you previously used"} |
| 102 | + inputType={'password'} |
| 103 | + width={"347px"} |
| 104 | + height={"56px"} |
| 105 | + margin="0 0 0.5rem 0" |
| 106 | + disabledPWShowBtn={false} |
| 107 | + required={true}/> |
| 108 | + <Button id={'confirm-btn'} |
| 109 | + classes={'button__solid button__primary'} |
| 110 | + margin="1rem 0 1rem" |
| 111 | + name="Repair" |
| 112 | + width={'347px'} |
| 113 | + click={repair} /> |
| 114 | + {:else} |
| 115 | + <div class="flow-text-box text-body1">Valut not exists</div> |
| 116 | + <Button id={'back-btn'} |
| 117 | + classes={'button__solid button__primary'} |
| 118 | + margin="1rem 0 1rem" |
| 119 | + name="Home" |
| 120 | + width={'347px'} |
| 121 | + click={appHome} /> |
| 122 | + {/if} |
| 123 | + </div> |
| 124 | + {:else} |
| 125 | + <div class="flex-column flow-buttons alignc"> |
| 126 | + {#if repairSuccess} |
| 127 | + |
| 128 | + <h3 class="flow-text-box text-body1 text-green"> Your vault has been successfully repaired!</h3> |
| 129 | + <Button id={'home-btn'} |
| 130 | + classes={'button__solid button__primary'} |
| 131 | + margin="1rem 0 1rem" |
| 132 | + name="Home" |
| 133 | + width={'347px'} |
| 134 | + click={appHome} /> |
| 135 | + {:else} |
| 136 | + <h3 class="flow-text-box text-body1 text-error"> Repair vault failed. Please try again or contact the developer</h3> |
| 137 | + <Button id={'back-btn'} |
| 138 | + classes={'button__solid button__primary'} |
| 139 | + margin="1rem 0 1rem" |
| 140 | + name="Back" |
| 141 | + width={'347px'} |
| 142 | + click={() => { step = 1}} /> |
| 143 | + <Button id={'home-btn'} |
| 144 | + classes={'button__solid button__primary'} |
| 145 | + margin="1rem 0 1rem" |
| 146 | + name="Home" |
| 147 | + width={'347px'} |
| 148 | + click={appHome} /> |
| 149 | + {/if} |
| 150 | + </div> |
| 151 | + {/if} |
| 152 | + </div> |
| 153 | + |
| 154 | + </div> |
| 155 | + |
| 156 | + </LeftSideFullPage> |
| 157 | + </div> |
| 158 | +</div> |
| 159 | + |
0 commit comments