diff options
author | Renard | 2019-09-27 12:55:20 -0300 |
---|---|---|
committer | Renard | 2019-09-27 12:55:20 -0300 |
commit | 1ce71de003d02f1b1c0e4a6ddd65cdb087d594c3 (patch) | |
tree | dbc9e03c77e4482d2ac1cd417b3486252b358f96 /src/App.js | |
parent | 522b92fbf7d2f79f6fe5dd9395c3175f8161053d (diff) | |
download | bai-client-1ce71de003d02f1b1c0e4a6ddd65cdb087d594c3.tar.gz bai-client-1ce71de003d02f1b1c0e4a6ddd65cdb087d594c3.tar.xz bai-client-1ce71de003d02f1b1c0e4a6ddd65cdb087d594c3.zip |
Añadido: Generación de contraseña para posts
Diffstat (limited to 'src/App.js')
-rw-r--r-- | src/App.js | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -60,6 +60,29 @@ class App extends Component { } else { this.setState({ nightMode: JSON.parse(_nightMode) }); } + let password = localStorage.getItem("password"); + if (password === null) { + localStorage.setItem("password", this.genPassword()); + } + } + + genPassword() { + let pass = ""; + for (let i = 0; i < 10; i++) { + let x = Math.round(Math.random() * 2); + switch (x) { + case 0: + pass += String.fromCharCode(48 + Math.round(Math.random() * 9)); + break; + case 1: + pass += String.fromCharCode(65 + Math.round(Math.random() * 25)); + break; + case 2: + pass += String.fromCharCode(97 + Math.round(Math.random() * 25)); + break; + } + } + return pass; } componentDidUpdate() { |