Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
+ Null Check for wallet get.
+ Key check while login.
  • Loading branch information
pushkar8723 committed Jun 2, 2018
1 parent 118ae96 commit 1d7c8f2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/app/DALs/WalletDAL.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public static function createWallet(String $address, int $timestamp, int $bcHeig

public static function getWallet(String $address) {
$wallet = Wallet::where('address', $address)->first();
if ($wallet->transfers[0] == 'W') {
if ($wallet && $wallet->transfers[0] == 'W') {
$wallet->transfers = self::getFile($wallet->transfers);
}
if ($wallet->keyImages[0] == 'W') {
if ($wallet && $wallet->keyImages[0] == 'W') {
$wallet->keyImages = self::getFile($wallet->keyImages);
}
Log::debug($wallet);
Expand Down
6 changes: 6 additions & 0 deletions src/app/Services/WalletService.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ public function setWallet(Request $request) {
throw error::getBadRequestException(error::WALLET_NOT_FOUND);
}

// Check if wallet address matches the key
$this->rpcService->setWallet(new SetWalletRequest(
$address, $viewKey, $wallet->createTime, $wallet->bcHeight,
$wallet->transfers, $wallet->keyImages
));

// Generate a new session.
$request->session()->regenerate();

Expand Down
2 changes: 2 additions & 0 deletions src/app/Utils/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class error
const SESSION_EXPIRED = "sessionExpired";
const REFRESH_LOCKED = "refreshLocked";
const WALLET_ALREADY_RESET = "walletAlreadyReset";
const WALLET_KEY_MISMATCH = "walletKeyMismatch";

/**
* Contains all error code and description for each key.
Expand All @@ -46,6 +47,7 @@ class error

// Wallet erros
self::WALLET_ALREADY_RESET => array("code" => 1200, "message" => "Wallet can be reset only once. Contact admins"),
self::WALLET_KEY_MISMATCH => array("code" => 1201, "message" => "Provided key didn't match the address."),

// These errors should never happen!
// Its over 9000! :P
Expand Down
3 changes: 3 additions & 0 deletions src/public/js/controllers/registerCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ angular.module('aeonPocket').controller('registerCtrl', [
userService.create($scope.viewWallet).then(function(data) {
$mdToast.showSimple("Account Created");
$state.go('public.login');
}, function (data) {
$scope.viewWalletForm.address.$setValidity('validation', false);
$scope.errorMessage = data.message;
});
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/public/templates/views/public/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ <h1 class="text-center" style="color: #fff;">
</md-card>

<md-card class="loginBox" ng-show="step==3" style="overflow-y: auto;">
<form name="viewWalletForm" layout="column" ng-submit="registerViewOnlyWallet()">
<form name="viewWalletForm" layout="column" ng-submit="registerViewOnlyWallet()" autocomplete="off">
<div layout="column">
<md-input-container>
<label>Your Wallet Address</label>
<input ng-disabled="inProgress" required name="address" ng-model="viewWallet.address" />
<div class="validation-messages" ng-messages="viewWalletForm.address.$error">
<div ng-message="required" ng-show="viewWalletForm.address.$error.required">Required</div>
<div ng-message="validation" ng-show="viewWalletForm.address.$error.validation">{{errorMessage}}</div>
</div>
</md-input-container>
<md-input-container>
Expand Down

0 comments on commit 1d7c8f2

Please sign in to comment.