Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 01 22:23

    LuckyCyborg on 4.2

    Small changes (compare)

  • Dec 01 21:55

    LuckyCyborg on 4.2

    Overall improvements (compare)

  • Nov 25 23:02

    LuckyCyborg on 4.2

    Small changes (compare)

  • Nov 25 23:00

    LuckyCyborg on 4.2

    Small changes (compare)

  • Nov 25 20:25

    LuckyCyborg on 4.2

    Small changes (compare)

  • Nov 24 19:21

    LuckyCyborg on 4.2

    Small changes (compare)

  • Nov 24 18:04

    LuckyCyborg on 4.2

    Small changes (compare)

  • Nov 24 17:47

    LuckyCyborg on 4.2

    Improve the Localization (compare)

  • Nov 24 17:33

    LuckyCyborg on 4.2

    Improve the Localization (compare)

  • Nov 24 17:30

    LuckyCyborg on 4.2

    Improve the Localization (compare)

  • Nov 24 17:11

    LuckyCyborg on 4.2

    Improve the Localization (compare)

  • Nov 24 17:04

    LuckyCyborg on 4.2

    Improve the App\Providers\AppSe… (compare)

  • Nov 24 17:04

    LuckyCyborg on 4.2

    Improve the App\Providers\AppSe… (compare)

  • Nov 24 17:01

    LuckyCyborg on 4.2

    Update the Localization (compare)

  • Nov 24 16:47

    LuckyCyborg on 4.2

    Improve the App\Providers\AppSe… (compare)

  • Nov 24 16:46

    LuckyCyborg on 4.2

    Improve the App\Providers\AppSe… (compare)

  • Nov 24 16:46

    LuckyCyborg on 4.2

    Improve the Localization (compare)

  • Nov 24 11:36

    LuckyCyborg on 4.2

    Improve the Routing (compare)

  • Nov 24 09:33

    LuckyCyborg on 4.2

    Improve the Routing (compare)

  • Nov 23 22:38

    LuckyCyborg on 4.2

    Overall improvements (compare)

ZhaoLin1457
@ZhaoLin1457
@LuckyCyborg OK. I will do it. :+1:
I talk about the git variant of cloning.
LuckyCyborg
@LuckyCyborg

@LuckyCyborg the composer.json file will need updating so it has its own name then I can add it to packagist

Thanks! I will update this evening the novapress repo.

And yes, I have not registered it to packagist.
David Carr
@daveismyname
okay great I’m happy to do it once ready]
LuckyCyborg
@LuckyCyborg
I need to update every branch or only the current one?
David Carr
@daveismyname
just the lastest branch I think
LuckyCyborg
@LuckyCyborg
1.1 is the current branch on Nova Press
LuckyCyborg
@LuckyCyborg
Thanks! :+1:
ZhaoLin1457
@ZhaoLin1457
@daveismyname @LuckyCyborg Thank you! :clap:
ZhaoLin1457
@ZhaoLin1457

@LuckyCyborg You are right, I had a typo on my setup.

View::addExtension('.tpl.php', 'template');

Please note the point from begining of extension. And here I written right the command which works...

View::addExtension('tpl.php', 'template');
LuckyCyborg
@LuckyCyborg
Happens... :smiling_imp:
LuckyCyborg
@LuckyCyborg

@daveismyname I have update also the composer.json from the branches of https://github.com/nova-framework/app

Please be kind to check if everything is OK on packagist side for this app.

David Carr
@daveismyname
all looks good
LuckyCyborg
@LuckyCyborg
:+1:
David Carr
@daveismyname

@daveismyname How about a tutorial about deploying a Nova 4.2 site?

that’s a good idea, I plan to first rebuild the novawebsite in 4.2

tejashp77
@tejashp77

@daveismyname

HP@DESKTOP-7TPCTSP MINGW64 /c/xampp/htdocs/nova
$ php forge module:migrate

There are no commands defined in the "module" namespace.

any idea on this?
David Carr
@daveismyname
try using php forge package:migrate
AlessandroLeone
@AlessandroLeone
hi, there's a way to allow a XMLHttpRequest by ajax call to another website? Because it has been blocked by CORS policy
thanks
David Carr
@daveismyname
I’ve just asked a collegue who has worked with cors in the past he says using this in .htaccess file worked for him:
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Access-Control-Allow-Origin"
Header always set Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS”
AlessandroLeone
@AlessandroLeone
thanks for the answer, in this way the website is vulnerable to various external attack or access, can I allow access only for single request?
David Carr
@daveismyname
ah I don’t know but this looks like a detailed guide on cors maybe this will help you. https://www.moesif.com/blog/technical/cors/Authoritative-Guide-to-CORS-Cross-Origin-Resource-Sharing-for-REST-APIs/#
AlessandroLeone
@AlessandroLeone
thanks so much
David Carr
@daveismyname
good luck :thumbsup:
ZhaoLin1457
@ZhaoLin1457

Hi, guys!

I solved the CORS issues on Nova 4.2 per route, in the following way:

// /app/Middleware/Cors.php

namespace App\Middleware;

use Closure;


class Cors
{
    public function handle($request, Closure $next)
    {
        return call_user_func($next, $request)
            ->header('Access-Control-Allow-Origin', '*')
            ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
    }
}
// /app/Config/App.php

/**
 * The Application's route Middleware.
 */
'routeMiddleware' => array(
    'auth'     => 'Nova\Auth\Middleware\Authenticate',
    'guest'    => 'App\Middleware\RedirectIfAuthenticated',
    'throttle' => 'Nova\Routing\Middleware\ThrottleRequests',
    'cors'     => 'App\Middleware\Cors', // <--- Add this line
),
// /app/Routes/Api.php

Route::get('cors-works-here', array('middleware' => 'cors', function ()
{
    return 'CORS works here!';
}));

The example route responds on /api/cors-works-here and I suggest to people to limit their CORS routes to API, because the WEB way on Nova is basically a true fort defending the app against CORS.

Everything there fights against CORS, from sessions to auth system.

David Carr
@daveismyname
:clap: excellent! I need to add this to the website.
ZhaoLin1457
@ZhaoLin1457
@daveismyname I will be glad.
I use also a variant of this middleware:
// /app/Middleware/Cors.php

namespace App\Middleware;

use Closure;


class Cors
{
    public function handle($request, Closure $next)
    {
        return call_user_func($next, $request)
            ->header('Access-Control-Allow-Origin', '*')
            ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
            ->header('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, X-Token-Auth, Authorization');
    }
}
This one apparently works better with the AJAX functions from jQuery
David Carr
@daveismyname
Thanks, appreciate it
LuckyCyborg
@LuckyCyborg

@ZhaoLin1457 Hmm...

This thing is really nasty: ->header('Access-Control-Allow-Origin', '*')

Maybe it's good enough for tests, but on the wild I will prefer to enforce the acceptance of well known CORS origins, like in something similar with:

class Cors
{
    protected $container;


    public function __construct(Container $container)
    {
        $this->container = $container;
    }

    public function handle($request, Closure $next)
    {
        $config = $this->container['config'];

        // Get the "Origin" header from Request.
        $origin = $request->header('Origin', $url = $config->get('app.url'));

        // Handle the middleware flow and retrieve the Response.
        $response = $next($request);

        // Retrieve all accepted CORS origins.
        $origins = array_merge((array) $url, $config->get('cors.origins', array()));

        if (! in_array($origin, $origins)) {
            return $response;
        }

        return $response->header('Access-Control-Allow-Origin', $origin)
            ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
            ->header('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, X-Token-Auth, Authorization');
    }
}

There is supposed that the valid CORS origins are enumerated in an array from a config file app/Config/Cors.php

LuckyCyborg
@LuckyCyborg

And regarding the API and Auth System, there's a way to use stateless authenticated requests via API: using the Token Guard.

In theory, you need a special API authentication endpoint, which returns a token on successful logins. Then this token should beused to authorize the following requests.

This Token Guard is different from the usual Session Guard, used on WEB routes, and special designed for APIs.
DonWagner
@DonWagner

Hey All... Long time no see.

I was trying to install the framework, but when running composer update, i got this error:

In ProviderRepository.php line 147: Class 'Nova\Database\SeedingServiceProvider' not found

Is that something you know about?

David Carr
@daveismyname

hey @DonWagner, hope your keeping well.

Did you install /app or /framework repo?

I’ve just installed from app using composer create-project nova-framework/framework novatemp that installed correctly I’ve then connected to a database and ran php forge seed that worked also did php forge db:seed and also tried php forge package:migrate and php forge package:seed all worked without issue

ah that’s the framework repo let me try it again with app.
DonWagner
@DonWagner

I think i found my mistake... I belive that i somehow got the wrong version installed. I'm trying again...

Yeah i'm doing okay, even though a lot of changes happens on my job. The last 2 years has been chaotic

David Carr
@daveismyname
oh sorry to hear that, just installed via app that’s okay no packages come with it by default so no package to seed.
DonWagner
@DonWagner
I'll do that :)
DonWagner
@DonWagner

A new Q from the Dane...

Now I have searched and searched, but I have not been able to find an answer I could use. That is why I now ask in here.
How to easily create a list of users without the users mentioned in another table.

Eg: In my database I have the User table with a column called zip code. I also have a table called Cities with a list of zip codes.
Now I would like to make a list of the users from the User table, which does not have the zip codes that are in the Cities table.

How to do it easiest? Or smartest?

David Carr
@daveismyname

I’ve been re-reading this a few times I don’t quite get what you need as you can select all users where the zipcode is empty, but it sounds like that’s not what you need.

To select all users that does not have a zip code but is in the cities table? how does a user relate to the cities table?

DonWagner
@DonWagner

Thanks Dave, i will try to explain in another way.
It's only a test setup, to learn from. So there is no logic why i'm using zip codes, that could be anything :laughing:

I have made a table with 100 users, all with a zip code (they don't have the same zip code):

id|name|zip_code

Then i have another table called Cities, where i'm adding some cities and there zip codes:

id|city|zip_code|

I then have a list of all the users. Then every time a new city is added to the Cities tabel, the users from the same zip_code, as the newly added city, will be removed from the list.

I hope that made more sens :smil:

David Carr
@daveismyname
ah okay so anytime you had a zip code to a user you could remove all entries from the cities table where the zip matches the new user.
DonWagner
@DonWagner

Thank you for your patience. I apologize for being poor at explaining.

I try like this:
I would like to make a list of users who come from zip codes that are not in the Cities table.

So the list will look like this:

Martin 8240
Otherwise 8210
Christian 8200
Niels 8000.

Then I add Aarhus C | 8200 to theCities table and I add Aarhus V | 8210

Then the list will look like this:

Martin 8240
Niels 8000

It's certainly simple, but I can't tell if you need to use whereNotIn. I can't really make it work

David Carr
@daveismyname
DonWagner
@DonWagner
Thanks, but i had a little problem, now i solved it, it was pretty easy when thinking about it.
        $users= DB::table("users")->select('*')
            ->whereNOTIn('zip_code',function($query){
               $query->select('zip_codes')->from('cities');
            })
        ->get();
David Carr
@daveismyname
nice :clap: