Skip to content

Commit

Permalink
Merge pull request #75 from piotr-iohk/update/pass/using/mnemonics
Browse files Browse the repository at this point in the history
Update passphrase using menmonic sentence
  • Loading branch information
piotr-iohk authored May 26, 2022
2 parents 70c4565 + 4ec05cb commit add76d3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
15 changes: 15 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,21 @@
redirect "/wallets/#{params[:wal_id]}"
end

get "/wallets/:wal_id/update-pass-mnem" do
wal = @cw.shelley.wallets.get params[:wal_id]
handle_api_err wal, session
erb :form_wallet_update_pass_mnem, { :locals => { :wal => wal } }
end

post "/wallets/:wal_id/update-pass-mnem" do
m = prepare_mnemonics params[:mnemonic_sentence]
r = @cw.shelley.wallets.update_passphrase(params[:wal_id],
{mnemonic_sentence: m,
new_passphrase: params[:new_pass]})
handle_api_err r, session
redirect "/wallets/#{params[:wal_id]}"
end

get "/wallets-delete/:wal_id" do
@cw.shelley.wallets.delete params[:wal_id]
redirect "/wallets"
Expand Down
10 changes: 8 additions & 2 deletions views/form_wallet_update_pass.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ wid = wal['id']
<div class="list-group-item">
<form action="<%= (url_path.include? "byron") ? byron_ep : shelley_ep %>" method="POST">
<div class="form-group">
<label for="epoch_number">Old pass</label>
<label for="old_pass">
<% if (url_path.include? "byron") %>
Old pass
<% else %>
Old pass / <a href="<%= (url_path.include? "byron") ? byron_ep : shelley_ep %>-mnem">Wallet mnemonics</a>
<% end %>
</label>
<input type="text" class="form-control" name="old_pass" id="old_pass"
placeholder="Old pass" value="Secure Passphrase">
<label for="epoch_number">New pass</label>
<label for="new_pass">New pass</label>
<input type="text" class="form-control" name="new_pass" id="new_pass"
placeholder="New pass" value="">
</div>
Expand Down
25 changes: 25 additions & 0 deletions views/form_wallet_update_pass_mnem.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<%
# Only supported for Shelley wallets
url_path = request.env['PATH_INFO'].to_s
byron_ep = "/byron-wallets/#{wal['id']}/update-pass" # -mnem
shelley_ep = "/wallets/#{wal['id']}/update-pass" # -mnem
wid = wal['id']
%>
<div class="list-group">
<div class="list-group-item">
<small><a href="<%= (url_path.include? "byron") ? "/byron-wallets/" : "/wallets/" %><%= wid %>">go back to wallet</a></small>
</div>
<div class="list-group-item">
<form action="<%= (url_path.include? "byron") ? byron_ep : shelley_ep %>-mnem" method="POST">
<div class="form-group">
<label for="mnemonic_sentence"><a href="<%= (url_path.include? "byron") ? byron_ep : shelley_ep %>">Old pass</a> / Wallet mnemonics</label>
<input type="text" class="form-control" name="mnemonic_sentence" id="mnemonic_sentence"
placeholder="Mnemonic sentence" value="">
<label for="new_pass">New pass</label>
<input type="text" class="form-control" name="new_pass" id="new_pass"
placeholder="New pass" value="">
</div>
<button type="submit" class="btn btn-success">Update passphrase</button>
</form>
</div>
</div>

0 comments on commit add76d3

Please sign in to comment.