mrkowala

mrkowala

Member Since 10 Months Ago

Experience Points 3,710
Experience
Level
Lessons Completed 36
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

11 Jan
1 week ago

mrkowala left a reply on Auth:api Middleware Routes Being Redirected To Login Route (passport)

I was able to find a solution! I had to add the following the my .htaccess in the public folder

Handle Authorization Header

RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

mrkowala started a new conversation Auth:api Routes Being Redirected To Login Route (passport)

So I've seen a lot of people posting about this, but most of the time it appears to be issues with the headers (which I'm not dismissing in this case), but here's the situation:

APIPostsController.php

<?php

namespace App\Http\Controllers\API;

use Illuminate\Http\Request;

use App\Post;
use App\Http\Controllers\Controller;

class APIPostsController extends Controller
{

    
    public function apiPosts()
    {
    //Just for testing purposes

        return response()->json([
            'name' => 'Abigail',
            'state' => 'CA'
        ]);
    }
}

api.php

<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/


Route::get('/v1/posts/','API\[email protected]');

I am currently able to go to oauth/token to request an access_token. Now, you'll notice in both of those files that there is no mention of the auth:api middleware - that's because as soon as I do that, the requests I send become 401: Unathenticated. The header I have is :

authorization: Bearer Accept: application/json

I'm able to get a response even without the token (obviously, since the middleware isn't be used). Any thoughts?

auth.php

/*
    |--------------------------------------------------------------------------
    | Authentication Guards
    |--------------------------------------------------------------------------
    |
    | Next, you may define every authentication guard for your application.
    | Of course, a great default configuration has been defined for you
    | here which uses session storage and the Eloquent user provider.
    |
    | All authentication drivers have a user provider. This defines how the
    | users are actually retrieved out of your database or other storage
    | mechanisms used by this application to persist your user's data.
    |
    | Supported: "session", "token"
    |
    */

    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
        ],
    ],
15 May
8 months ago

mrkowala started a new conversation Javascript AJAX Submit Being Overridden By HTML?

Here's what's happening:

The user uploads a new photo, and then is able to select the crop of the photo. When they submit, it submits the new profile photo but it does not crop it. Any thoughts?? It makes me feel as though when I click "submit" it's ignoring the JS (which is admittedly bad lolol)

The view:

<form method="POST" action="/updateprofilephoto" enctype="multipart/form-data">
      {{ csrf_field() }}
   

        <div class="updateprofileimagebutton">

          
        <div class="file is-small has-name" id="imageurl">
                <label class="file-label">
                  <input class="file-input" type="file" name="image" id="upload">
                  <span class="file-cta">
                    <span class="file-icon">
                      <i class="fas fa-upload"></i>
                    </span>
                    <span class="file-label">
                      Change Profile Photo
                    </span>
                  </span>
                  <div id="thefilename">
                    
    
                  </div>
            
                </label>
                <div id="saveprofileimage">

                    <div class="control">
                        <button id="upload-result" class="button is-primary is-small">Save Now!</button>
                      </div>
              
                </div>
              </div>
            </div>
  
          </form>

```



The Javascript:
```
$.ajaxSetup({
  headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  }
  });
  
  $picurl =  document.getElementById('theprofilepic').src;
  console.log($picurl);
  $uploadCrop = $('#profilepicture').croppie({
      enableExif: true,
      viewport: {
        url: $picurl,
          width: 200,
          height: 200,
          type: 'square'
      },
      boundary: {
          width: 300,
          height: 300
      }
  });

$uploadCrop.croppie('bind',{url: $picurl});
 
  
  $('#upload').on('change', function () { 
    var reader = new FileReader();
      reader.onload = function (e) {
        $uploadCrop.croppie('bind', {
          url: e.target.result
        }).then(function(){
          console.log('jQuery bind complete');
        });
      }
      reader.readAsDataURL(this.files[0]);
  });
  




  $( "#upload-result" ).click(function(ev) {
    console.log("LOL");
    $uploadCrop.croppie('result', {
      type: 'canvas',
      size: 'viewport'
    }).then(function (resp) {
      $.ajax({
        url: "https://www.coslay.co/updateprofilephoto",
        method: "POST",
        data: {"image":resp},
        success: function (data) {
          html = '<img src="' + resp + '" />';
          $("#upload-demo-i").html(html);
        }
      });
    });
});
```