Skip to content

Commit

Permalink
display public key on accounts page (decred#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandoabolafio authored and dajohi committed Apr 12, 2018
1 parent 4fe9ec7 commit 18ee833
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 35 deletions.
98 changes: 63 additions & 35 deletions src/components/AccountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PrivateKeyIdentityManager from "./PrivateKeyIdentityManager";
import PasswordChange from "./PasswordChange";
import Message from "./Message";
import connector from "../connectors/updateKey";
import { myPubKeyHex } from "../lib/pki";

const UpdatedKeyMessage = ({ email }) => (
<span>
Expand All @@ -11,41 +12,68 @@ const UpdatedKeyMessage = ({ email }) => (
</span>
);

const KeyPage = ({
loggedInAs,
onUpdateUserKey,
updateUserKey,
updateUserKeyError
}) => (
<div className="content" role="main">
<div className="page user-profile-page">
<h1>Private Key</h1>
{updateUserKey &&
updateUserKey.success && (
<Message
type="success"
header="Key Updated"
body={<UpdatedKeyMessage email={loggedInAs} />}
class KeyPage extends React.Component {
constructor(props) {
super(props);
this.state = {
pubkey: ""
};
}
componentDidMount() {
const { loggedInAs } = this.props;
myPubKeyHex(loggedInAs).then(
(pubkey) => {
this.setState({
pubkey
});
}
);
}
render() {
const {
loggedInAs,
onUpdateUserKey,
updateUserKey,
updateUserKeyError
} = this.props;
const { pubkey } = this.state;
return (
<div className="content" role="main">
<div
style={{ display: "flex", flexDirection: "column" }}
className="page user-profile-page">
<h1>Key management</h1>
{ pubkey && <span>Current Public key: {pubkey}</span>}
{updateUserKey &&
updateUserKey.success && (
<Message
type="success"
header="Key Updated"
body={<UpdatedKeyMessage email={loggedInAs} />}
/>
)}
{updateUserKeyError && (
<Message
type="error"
header="Error"
body={updateUserKeyError.message}
/>
)}
<button
style={{ maxWidth: "144px" }}
onClick={() => onUpdateUserKey(loggedInAs)}>
Update Key Pair
</button>
<PrivateKeyIdentityManager
loggedInAs={loggedInAs}
onUpdateUserKey={onUpdateUserKey}
/>
)}
{updateUserKeyError && (
<Message
type="error"
header="Error"
body={updateUserKeyError.message}
/>
)}
<button onClick={() => onUpdateUserKey(loggedInAs)}>
Update Key Pair
</button>
<PrivateKeyIdentityManager
loggedInAs={loggedInAs}
onUpdateUserKey={onUpdateUserKey}
/>
<h1>Change Password</h1>
<PasswordChange />
</div>
</div>
);
<h1>Change Password</h1>
<PasswordChange />
</div>
</div>
);
}
}

export default connector(KeyPage);
Empty file.

0 comments on commit 18ee833

Please sign in to comment.