• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

marscoin / martianrepublic / 22677277751

04 Mar 2026 03:53PM UTC coverage: 5.241% (+0.04%) from 5.205%
22677277751

push

github

Lennart Lopin
perf: optimize page load with caching and query improvements

0 of 66 new or added lines in 4 files covered. (0.0%)

1 existing line in 1 file now uncovered.

190 of 3625 relevant lines covered (5.24%)

0.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/Http/Controllers/Wallet/DashboardController.php
1
<?php
2

3
namespace App\Http\Controllers\Wallet;
4

5
use App\Http\Controllers\Controller;
6
use PragmaRX\Google2FA\Google2FA;
7
use BaconQrCode\Renderer\ImageRenderer;
8
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
9
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
10
use BaconQrCode\Writer;
11
use Illuminate\Http\Request;
12
use Illuminate\Support\Facades\Auth;
13
use Illuminate\Support\Facades\View;
14
use Illuminate\Support\Facades\Cache;
15
use App\Models\Profile;
16
use App\Models\HDWallet;
17
use App\Models\Proposals;
18
use App\Models\IPFSRoot;
19
use App\Models\User;
20
use App\Models\Voucher;
21
use App\Includes\jsonRPCClient;
22
use App\Includes\AppHelper;
23
use App\Models\CivicWallet;
24
use Illuminate\Support\Facades\Log;
25
use Exception;
26

27
class DashboardController extends Controller
28
{
29

30
        /**
31
         * Setup the layout used by the controller.
32
         *
33
         * @return void
34
         */
35

36
        public function __construct()
×
37
        {
38
        }
×
39

40

41
        public function index()
×
42
    {
43
        return Cache::rememberForever('home.dashboard', function () {
×
44
            return view('dashboard')->render();
×
45
        });
×
46
    }
47

48

49
        protected function showLogout()
×
50
        {
51

52
                if (Auth::check()) {
×
53
                        $uid = Auth::user()->id;
×
54
                        $profile = Profile::where('userid', '=', $uid)->first();
×
55

56
                        $profile->wallet_open = 0;
×
57
                        $profile->civic_wallet_open = 0;
×
58
                        $profile->save();
×
59
                }
60

61
                Auth::logout();
×
62

63
                return redirect('/login');
×
64
        }
65

66

67
        protected function show2FA(Request $request)
×
68
        {
69

70
                if (Auth::check()) {
×
71
                        $email = Auth::user()->email;
×
72
                        $uid = Auth::user()->id;
×
73
                        $google2fa = app(Google2FA::class);
×
74
                        $secret = $request->input('secret');
×
75
                        if ($secret) {
×
76
                                $view = View::make('wallet.hello2fa');
×
77
                                $view->qrcode_image = NULL;
×
78
                                $profile = Profile::where('userid', '=', Auth::user()->id)->first();
×
79
                                $google2fa_secret = $profile->twofakey;
×
80
                                $valid = $google2fa->verifyKey($google2fa_secret, $secret);
×
81

82

83

84
                                if ($valid) {
×
85
                                        $profile->twofaset = 1;
×
86
                                        $profile->save();
×
87
                                        $view->isvalid = "Success";
×
88
                                        return redirect('wallet/dashboard');
×
89
                                } else {
90
                                        $view->isvalid = "Failed";
×
91
                                }
92

93

94

95
                                return $view;
×
96
                        } else {
97
                                $profile = Profile::where('userid', '=', Auth::user()->id)->first();
×
98

99
                                if (!$profile) {
×
100
                                        $key = $google2fa->generateSecretKey();
×
101
                                        $g2faUrl = $google2fa->getQRCodeUrl(
×
102
                                                'marscoinwallet',
×
103
                                                $email,
×
104
                                                $key
×
105
                                        );
×
106

107

108

109
                                        $profile = new Profile;
×
110
                                        $profile->userid = $uid;
×
111
                                        $profile->twofaset = 0;
×
112
                                        $profile->twofakey = $key;
×
113
                                        $profile->save();
×
114
                                        $writer = new Writer(
×
115
                                                new ImageRenderer(
×
116
                                                        new RendererStyle(300),
×
117
                                                        new ImagickImageBackEnd()
×
118
                                                )
×
119
                                        );
×
120

121
                                        $view = View::make('wallet.hello2fa');
×
122
                                        $view->isvalid = NULL;
×
123
                                        $view->qrcode_image = base64_encode($writer->writeString($g2faUrl));
×
124
                                        return $view;
×
125
                                } else if ($profile && $profile->twofaset == 0) {
×
126

127

128
                                        $key = $google2fa->generateSecretKey();
×
129
                                        $g2faUrl = $google2fa->getQRCodeUrl(
×
130
                                                'marscoinwallet',
×
131
                                                $email,
×
132
                                                $key
×
133
                                        );
×
134

135
                                        $profile->userid = $uid;
×
136
                                        $profile->twofakey = $key;
×
137
                                        $profile->save();
×
138

139
                                        $writer = new Writer(
×
140
                                                new ImageRenderer(
×
141
                                                        new RendererStyle(300),
×
142
                                                        new ImagickImageBackEnd()
×
143
                                                )
×
144
                                        );
×
145
                                        $view = View::make('wallet.hello2fa');
×
146
                                        $view->isvalid = NULL;
×
147
                                        $view->qrcode_image = base64_encode($writer->writeString($g2faUrl));
×
148

149
                                        return $view;
×
150
                                }
151
                                // else
152
                                // {
153
                                //         return redirect('wallet/dashboard');
154
                                // }
155
                        }
156
                } else {
157
                        return redirect('/login');
×
158
                }
159
        }
160

161

162
        protected function show2FAChallenge(Request $request)
×
163
        {
164
                if (Auth::check()) {
×
165
                        $email = Auth::user()->email;
×
166
                        $uid = Auth::user()->id;
×
167
                        $google2fa = app(Google2FA::class);
×
168
                        $secret = $request->input('secret');
×
169

170

171

172
                        if ($secret) {
×
173
                                $profile = Profile::where('userid', '=', Auth::user()->id)->first();
×
174
                                $google2fa_secret = $profile->twofakey;
×
175
                                $valid = $google2fa->verifyKey($google2fa_secret, $secret);
×
176
                                if ($valid) {
×
177

178
                                        $profile->openchallenge = 0;
×
179
                                        $profile->save();
×
180

181
                                        return redirect('wallet/dashboard');
×
182
                                } else {
183
                                        $view = View::make('wallet.challenge2fa');
×
184
                                        return $view;
×
185
                                }
186
                        } else {
187
                                $view = View::make('wallet.challenge2fa');
×
188
                                return $view;
×
189
                        }
190
                } else {
191
                        return redirect('/login');
×
192
                }
193
        }
194

195

196
        protected function showChallenge()
×
197
        {
198
                if (Auth::check()) {
×
199
                        //check if 2FA is on. If not, go to 2FA screen first
200
                        $uid = Auth::user()->id;
×
201
                        $profile = Profile::where('userid', '=', $uid)->first();
×
202
                        if (!$profile) {
×
203
                                return redirect('/twofa');
×
204
                        } else {
205
                                $is2faset = $profile->twofaset;
×
206
                                $profile->openchallenge = 1;
×
207
                                $profile->wallet_open = 0;
×
208
                                $profile->save();
×
209
                                if (!$is2faset) {
×
210
                                        return redirect('/twofa');
×
211
                                } else {
212
                                        return redirect('/twofachallenge');
×
213
                                }
214
                        }
215
                } else {
216
                        return redirect('/login');
×
217
                }
218
        }
219

220
        protected function showDashboard()
×
221
        {
222
                if (Auth::check()) {
×
223
                        $uid = Auth::user()->id;
×
224
                        $profile = Profile::where('userid', '=', $uid)->first();
×
225
                        $wallet = HDWallet::where('user_id', '=', $uid)->get();
×
226
                        $civic_wallet = CivicWallet::where('user_id', '=', $uid)->first();
×
227
                        if (!$profile) {
×
228
                                return redirect('/twofa');
×
229
                        } else {
230
                                if ($profile->openchallenge == 1 || is_null($profile->openchallenge)) {
×
231
                                        return redirect('/twofachallenge');
×
232
                                }
233
                        }
234
                        $view = View::make('wallet.dashboard');
×
235
                        $view->public_addr = "";
×
236

NEW
237
                        if($profile->wallet_open > 0){
×
NEW
238
                                $openhdwallet = HDWallet::where('id', '=', $profile->wallet_open)->first();
×
NEW
239
                                if ($openhdwallet) {
×
240
                                        $view->public_addr = $openhdwallet->public_addr;
×
241
                                        $view->received = AppHelper::getMarscoinTotalReceived($openhdwallet->public_addr);
×
242
                                        $view->sent = AppHelper::getMarscoinTotalSent($openhdwallet->public_addr);
×
243
                                        $view->has_civic_wallet = true;
×
244
                                        $view->has_wallet = true;
×
245
                                        $view->wallet_open = true;
×
246
                                } else {
NEW
247
                                        $profile->wallet_open = 0;
×
NEW
248
                                        $profile->save();
×
249
                                        $view->balance = 0;
×
250
                                        $view->received = 0;
×
251
                                        $view->sent = 0;
×
252
                                        $view->has_civic_wallet = false;
×
253
                                        $view->has_wallet = false;
×
254
                                        $view->wallet_open = false;
×
255
                                }
256
                        }
NEW
257
                        else if($profile->civic_wallet_open > 0 && $civic_wallet)
×
258
                        {
NEW
259
                                $view->public_addr = $civic_wallet->public_addr;
×
NEW
260
                                $view->received = AppHelper::getMarscoinTotalReceived($civic_wallet->public_addr);
×
NEW
261
                                $view->sent = AppHelper::getMarscoinTotalSent($civic_wallet->public_addr);
×
NEW
262
                                $view->has_civic_wallet = true;
×
NEW
263
                                $view->has_wallet = true;
×
NEW
264
                                $view->wallet_open = true;
×
265
                        }
266
                        else
267
                        {
NEW
268
                                $view->balance = 0;
×
NEW
269
                                $view->received = 0;
×
NEW
270
                                $view->sent = 0;
×
NEW
271
                                $view->has_civic_wallet = false;
×
NEW
272
                                $view->has_wallet = false;
×
NEW
273
                                $view->wallet_open = false;
×
274
                        }
275

NEW
276
                        $view->transactions = array();
×
277

278
                        // Cache dashboard stats to reduce DB/API calls on every page load
NEW
279
                        $view->coincount = AppHelper::getMarscoinTotalAmount();
×
NEW
280
                        $view->forum_count = Cache::remember('forum_recent_count', 300, function () {
×
NEW
281
                                return AppHelper::checkForRecentPosts();
×
NEW
282
                        });
×
NEW
283
                        $view->proposal_count = Cache::remember('proposal_open_count', 300, function () {
×
NEW
284
                                return Proposals::countOpenProposals();
×
NEW
285
                        });
×
NEW
286
                        $citizenStatus = AppHelper::getCitizenStatus($uid);
×
NEW
287
                        $view->citizen_status = $citizenStatus ? $citizenStatus->type : 'GP';
×
288

NEW
289
                        return $view;
×
290
                } else {
291
                        return redirect('/login');
×
292
                }
293
        }
294

295
        // Wallet history
296

297
        // Show HD Wallet (Not Open)
298
        // /wallet/dashboard/hd
299
        protected function listHDWallet(Request $request)
×
300
        {
301
                if (Auth::check()) {
×
302
                        $uid = Auth::user()->id;
×
303
                        $profile = Profile::where('userid', '=', $uid)->first();
×
304

305
                        $key = $request->input('key');
×
306
                        if($key == "none")
×
307
                        {
308
                                Log::debug("Something went wrong with key storage");
×
309
                                $profile->wallet_open = 0;
×
310
                                $profile->civic_wallet_open = 0;
×
311
                                $profile->save();
×
312
                                return redirect('/wallet/dashboard');
×
313
                        }
314

315
                        //if wallet currently open, redirect to hd-open
316
                        if($profile->wallet_open > 0){
×
317
                                return redirect('/wallet/dashboard/hd-open');
×
318
                        }
319
                        if($profile->civic_wallet_open > 0){
×
320
                                return redirect('/wallet/dashboard/hd-open');
×
321
                        }
322

323
                        // list of all user wallets.
324
                        $wallets = HDWallet::where('user_id', '=', $uid)->get();
×
325

326
                        // only one civic wallet ever...
327
                        $civic_wallet = CivicWallet::where('user_id', '=', $uid)->first();
×
328

329
                        // get balance of wallets.
330
                        foreach($wallets as $wallet)
×
331
                        {
332
                                $wallet->balance = AppHelper::getMarscoinBalance($wallet->public_addr);
×
333
                        }
334

335
                        // handle redirects...
336
                        if (!$profile) {
×
337
                                return redirect('/twofa');
×
338
                        } else {
339
                                if ($profile->openchallenge == 1 || is_null($profile->openchallenge)) {
×
340
                                        return redirect('/twofachallenge');
×
341
                                }
342
                        }
343
                        if ($profile->wallet_open >= 1 && !is_null($wallets)) {
×
344
                                return redirect('/wallet/dashboard/hd-open');
×
345
                        }
346

347
                        $view = View::make('wallet.hd');
×
348
                        
349

350
                        if(!is_null($civic_wallet))
×
351
                        {
352
                                $view->civic_balance = AppHelper::getMarscoinBalance($civic_wallet->public_addr);
×
353
                                $view->network = AppHelper::getMarscoinNetworkInfo();
×
354
                                $view->public_addr = null;
×
355

356
                                $view->general_public = $profile->general_public;
×
357
                                $view->citizen = $profile->citizen;
×
358
                                $view->applied = $profile->has_application;
×
359
                                $view->wallet_open = $profile->civic_wallet_open;
×
360
                        }
361

362

363
                        if (is_null($civic_wallet)) {
×
364
                                $view->wallet_open = 0;
×
365
                                $view->wallets = null;
×
366
                                $view->encrypted_seed = null;
×
367
                                $view->civic_wallet = null;
×
368
                                $view->public_addr = null;
×
369
                                $view->citizen = null;
×
370
                                $view->applied = null;
×
371
                        } else {
372
                                $view->civic_wallet = $civic_wallet;
×
373
                                $view->wallet_open = $profile->wallet_open;
×
374
                                $view->encrypted_seed = $civic_wallet->encrypted_seed;
×
375
                                $view->wallets = $wallets;
×
376
                                $view->citizen = null;
×
377
                                $view->applied = null;
×
378
                        }
379

380
                        $data = json_decode(file_get_contents("/home/mars/constitution/marswallet.json"), true);
×
381
                        $view->SALT = $data['salt'];
×
382
                        $view->iv = $data['iv'];
×
383
                        return $view;
×
384
                } else {
385
                        return redirect('/login');
×
386
                }
387
        }
388

389
        // Show HD Wallet (Open)
390
        // /wallet/dashboard/hd-open
391
        protected function showHDOpen(Request $request)
×
392
        {
393
                if (Auth::check()) {
×
394
                        $uid = Auth::user()->id;
×
395
                        $profile = Profile::where('userid', '=', $uid)->first();
×
396
                        $wallets = HDWallet::where('user_id', '=', $uid)->get();
×
397
                        $civic_wallet = CivicWallet::where('user_id', '=', $uid)->first();
×
398

399
                        if (!$profile) {
×
400
                                return redirect('/twofa');
×
401
                        } else {
402
                                if ($profile->openchallenge == 1 || is_null($profile->openchallenge)) {
×
403
                                        return redirect('/twofachallenge');
×
404
                                }
405
                        }
406
                        $data = json_decode($request->input("wallet"));
×
407

408
                        if ($data || ($wallets || $civic_wallet)) {
×
409
                                // Fetch wallet info from profile if this is not a newly unlocked wallet
UNCOV
410
                                if(is_null($data)){
×
411
                                        $data = HDWallet::where('id', '=', $profile->wallet_open)->first();
×
412
                                }
413
                                if(is_null($data)){
×
414
                                        $data = CivicWallet::where('user_id', '=', $uid)->first();
×
415
                                }
416
                                if (is_null($data)) {
×
417
                                        $profile->wallet_open = 0;
×
418
                                        $profile->civic_wallet_open = 0;
×
419
                                        $profile->save();
×
420
                                        return redirect('/wallet/dashboard/hd');
×
421
                                }
422

423
                                $view = View::make('wallet.hd-open');
×
424

425
                                $codes = json_decode(file_get_contents("/home/mars/constitution/marswallet.json"), true);
×
426
                                $view->SALT = $codes['salt'];
×
427
                                $view->iv = $codes['iv'];
×
428

429
                                $view->public_addr = $data->public_addr;
×
430
                                $view->encrypted_seed = $data->encrypted_seed;
×
431
                                $view->fullname = Auth::user()->fullname;
×
432
                                $view->wallet_open = $data->id;
×
433

434
                                $isCivicWalletOpen = $civic_wallet && $data && $civic_wallet->id === $data->id;
×
435

436
                                if($isCivicWalletOpen){
×
437
                                        $profile->wallet_open = 0;
×
438
                                        $profile->civic_wallet_open = $civic_wallet->id;
×
439
                                        $view->is_civic_wallet = $isCivicWalletOpen;
×
440
                                }else{
441
                                        $profile->wallet_open = $data->id;
×
442
                                        $profile->civic_wallet_open = 0;
×
443
                                        $view->is_civic_wallet = 0;
×
444
                                }
445
                                $profile->save();
×
446

447
                                return $view;
×
448
                        }else{
449
                                return redirect('/wallet/dashboard/hd');
×
450
                        }
451

452
                } else {
453
                        return redirect('/login');
×
454
                }
455
        }
456

457

458
        // Show HD Wallet (Close)
459
        protected function showHDClose()
×
460
        {
461
                if (Auth::check()) {
×
462
                        $uid = Auth::user()->id;
×
463
                        $profile = Profile::where('userid', '=', $uid)->first();
×
464

465
                        if (!$profile) {
×
466
                                return redirect('/twofa');
×
467
                        } else {
468
                                if ($profile->openchallenge == 1 || is_null($profile->openchallenge)) {
×
469
                                        return redirect('/twofachallenge');
×
470
                                }
471
                        }
472
                        Log::info("set open wallet to zero");
×
473
                        $profile->wallet_open = 0;
×
474
                        $profile->civic_wallet_open = 0;
×
475
                        $profile->save();
×
476

477
                        return redirect('wallet/dashboard/hd');
×
478
                        
479

480
                } else {
481
                        return redirect('/login');
×
482
                }
483
        }
484

485

486
        protected function forgetWallet(Request $request)
×
487
        {
488
                if (Auth::check()) {
×
489
                        $uid = Auth::user()->id;
×
490
                        
491
                        $walletid = $request->input('hdwallet_id');
×
492
                        
493
                        $wallet = HDWallet::where('id', $walletid)->where('user_id', $uid)->firstOrFail();
×
494
                        
495
                        $wallet->delete();
×
496
                        
497
                        return response()->json(['success' => 'Wallet deleted successfully']);
×
498
                }
499
                return response()->json(['error' => 'Unauthorized'], 403);
×
500
        }
501

502

503
        public function postCreateWallet(Request $request)
×
504
        {
505
                if (Auth::check()) {
×
506
                        $uid = Auth::user()->id;
×
507
                        $profile = Profile::where('userid', '=', $uid)->first();
×
508
                        $hd_wallet = HDWallet::where('user_id', '=', $uid)->get();
×
509
                        $civic = CivicWallet::where('user_id', '=', $uid)->first();
×
510

511
                        Log::info("See if user has civic wallet");
×
512
                        // Check if the user has a Civic wallet already, even if it's not opened
513
                        $civicExists = CivicWallet::where('user_id', '=', $uid)->exists();
×
514

515
                        // user must insert password.. no null accepted...
516

517
                        // 3 States of Wallets: 
518
                        // 1) NO civic + No wallets
519
                        // 2) Civic + No wallets
520
                        // 3) Civic + wallets
521
                        if($request->input('wallet_name') == "Imported")
×
522
                        {
523
                                Log::debug("imported wallets are not being stored ... yet");
×
524
                                $new_wallet = new HDWallet;
×
525
                                $new_wallet->encrypted_seed = "ADHOC";
×
526
                                $new_wallet->public_addr = $request->input('public_addr');
×
527
                                $new_wallet->backup = 1;
×
528
                                $new_wallet->user_id = $uid;
×
529
                                $new_wallet->wallet_type = $request->input('wallet_name');;
×
530
                                $new_wallet->save();
×
531
                                $profile->wallet_open = $new_wallet->id;
×
532
                                $profile->civic_wallet_open = 0;
×
533
                                $profile->save();
×
534
                                return redirect('/wallet/dashboard/hd-open')->with('message', 'Wallet Successfully Opened!');
×
535
                        }
536
                        else if (!$civicExists && $profile->civic_wallet_open == 0 && $profile->wallet_open == 0) 
×
537
                        {
538
                                Log::debug("first wallet created has to be civic wallet");
×
539
                                $new_civic_wallet = new CivicWallet;
×
540
                                if(empty($request->input('password')))
×
541
                                        $new_civic_wallet->encrypted_seed = "UNSET";
×
542
                                else
543
                                        $new_civic_wallet->encrypted_seed = $request->input('password');
×
544
                                $new_civic_wallet->public_addr = $request->input('public_addr');
×
545

546
                                $new_civic_wallet->backup = 1;
×
547

548
                                $new_civic_wallet->user_id = $uid;
×
549
                                $new_civic_wallet->wallet_type = $request->input('wallet_name');
×
550
                                $new_civic_wallet->save();
×
551
                                
552
                                $profile->civic_wallet_open = $new_civic_wallet->id;
×
553
                                $profile->wallet_open = 0;
×
554
                                $profile->save();
×
555
                                return redirect('/wallet/dashboard/hd-open')->with('message', 'Wallet Successfully Opened!');
×
556
                        }
557
                        else if ($civicExists || $profile->civic_wallet_open == 1) 
×
558
                        {
559
                            Log::debug("non-civic wallet being created");
×
560
                                $new_wallet = new HDWallet;
×
561

562
                                $encseed = $request->input('password');
×
563
                                if(empty($encseed))
×
564
                                {
565
                                        $new_wallet->encrypted_seed = "ADHOC";
×
566
                                }
567
                                else{
568
                                        $new_wallet->encrypted_seed = $request->input('password');
×
569
                                }
570

571
                                $new_wallet->public_addr = $request->input('public_addr');
×
572

573
                                $new_wallet->backup = 1;
×
574

575
                                $new_wallet->user_id = $uid;
×
576
                                $new_wallet->wallet_type = $request->input('wallet_name');
×
577
                                
578
                                $new_wallet->save();
×
579

580
                                $profile->wallet_open = $new_wallet->id;
×
581
                                $profile->civic_wallet_open = 0;
×
582
                                $profile->save();
×
583
                                return redirect('/wallet/dashboard/hd-open')->with('message', 'Wallet Successfully Opened!');
×
584
                        }
585
                        else
586
                        {
587
                                Log::debug("no wallet entry created in local db cache");
×
588
                                return redirect('/wallet/dashboard/hd');
×
589
                        }
590
                        return redirect('/wallet/dashboard/hd');
×
591

592
                } else {
593

594
                        return redirect('/login');
×
595
                }
596
        }
597

598
        // GET
599
        // Open Pre-Existing Wallet
600
        public function getWallet(Request $request)
×
601
        {
602
                if (Auth::check()) {
×
603

604
                        $uid = Auth::user()->id;
×
605
                        $profile = Profile::where('userid', '=', $uid)->first();
×
606
                        $hd_wallet = HDWallet::where('user_id', '=', $uid)->get();
×
607
                        $profile->wallet_open = $hd_wallet->id;
×
608
                        $profile->save();
×
609

610
                        return redirect('wallet/dashboard/hd-open')->with('message', 'Wallet Successfully Open!');
×
611
                } else {
612
                        return redirect('/login');
×
613
                }
614
        }
615

616
        public function failWallet()
×
617
        {
618

619

620
                return redirect('wallet/dashboard/hd')->with('message', 'Wallet Unsuccessful!');
×
621
        }
622

623

624
        // Logout of Wallet ONLY
625
        public function walletLogout()
×
626
        {
627
                if (Auth::check()) {
×
628

629
                        $uid = Auth::user()->id;
×
630
                        $profile = Profile::where('userid', '=', $uid)->first();
×
631
                        $profile->wallet_open = 0;
×
632
                        $profile->civic_wallet_open = 0;
×
633
                        $profile->save();
×
634
                        return redirect('/wallet/dashboard');
×
635
                }
636

637
        }
638

639

640

641
        protected function showProfile()
×
642
        {
643
                if (Auth::check()) {
×
644
                        $uid = Auth::user()->id;
×
645
                        $profile = Profile::where('userid', '=', $uid)->first();
×
646
                        if (!$profile) {
×
647
                                return redirect('/twofa');
×
648
                        } else {
649
                                if ($profile->openchallenge == 1 || is_null($profile->openchallenge)) {
×
650
                                        return redirect('/twofachallenge');
×
651
                                }
652
                        }
653
                        $view = View::make('wallet.profile');
×
NEW
654
                        $view->network = AppHelper::getMarscoinNetworkInfo();
×
655

656
                        return $view;
×
657
                } else {
658
                        return redirect('/login');
×
659
                }
660
        }
661

662

663
        protected function showReports()
×
664
        {
665
                if (Auth::check()) {
×
666
                        $uid = Auth::user()->id;
×
667
                        $profile = Profile::where('userid', '=', $uid)->first();
×
668
                        if (!$profile) {
×
669
                                return redirect('/twofa');
×
670
                        } else {
671
                                if ($profile->openchallenge == 1 || is_null($profile->openchallenge)) {
×
672
                                        return redirect('/twofachallenge');
×
673
                                }
674
                        }
675
                        $view = View::make('wallet.reports');
×
NEW
676
                        $view->network = AppHelper::getMarscoinNetworkInfo();
×
677
                        return $view;
×
678
                } else {
679
                        return redirect('/login');
×
680
                }
681
        }
682

683

684

685
        protected function anchor()
×
686
        {
687

688
                if (Auth::check()) {
×
689
                        $uid = Auth::user()->id;
×
690
                        $profile = Profile::where('userid', '=', $uid)->first();
×
691
                        $wallet = HDWallet::where('user_id', '=', $uid)->first();
×
692

693
                        if (!$profile) {
×
694
                                return redirect('/twofa');
×
695
                        } else {
696
                                if ($profile->openchallenge == 1 || is_null($profile->openchallenge)) {
×
697
                                        return redirect('/twofachallenge');
×
698
                                }
699
                        }
700
                        $view = View::make('wallet.anchor');
×
701

702
                        if ($wallet) {
×
703
                                $view->public_address = $wallet['public_addr'];
×
704
                        } else {
705
                                $view->balance = 0;
×
706
                                $view->public_address = "";
×
707
                        }
708
                        return $view;
×
709
                } else {
710
                        return redirect('/login');
×
711
                }
712
        }
713

714
        protected function showCamera()
×
715
        {
716
                if (Auth::check()) {
×
717
                        $uid = Auth::user()->id;
×
718
                        $profile = Profile::where('userid', '=', $uid)->first();
×
719
                        if (!$profile) {
×
720
                                return redirect('/twofa');
×
721
                        } else {
722
                                if ($profile->openchallenge == 1 || is_null($profile->openchallenge)) {
×
723
                                        return redirect('/twofachallenge');
×
724
                                }
725
                        }
726
                        $view = View::make('wallet.camera');
×
727
                        $view->email = Auth::user()->email;
×
NEW
728
                        $view->network = AppHelper::getMarscoinNetworkInfo();
×
729

730
                        return $view;
×
731
                } else {
732
                        return redirect('/login');
×
733
                }
734
        }
735

736

737
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc