toddish / verify Goto Github PK
View Code? Open in Web Editor NEWLaravel Auth Bundle
License: MIT License
Laravel Auth Bundle
License: MIT License
Hi there,
In de documentation I read the following:
// Create a new Permission
$permission = new \Verify\Models\Permission;
$permission->name = 'delete_user';
$permission->save();
// Create a new Role
$role = new Verify\Models\Role;
$role->name = 'Moderator';
$role->level = 7;
$role->save();
// Assign the Permission to the Role
$role->permissions()->sync(array($permission->id));
// Create a new User
$user = new \Verify\Models\User;
$user->username = 'Todd';
$user->email = '[email protected]';
$user->password = 'password'; // This is automatically salted and encrypted
$user->save();
// Assign the Role to the User
$user->roles()->sync(array($role->id));
I created the roles and the permissions, so that's that.
Now when I create a new user.. how would I assign a existing role and/or
permission?
I would think I need to do something like
$role = \Verify\Models\Role::where_level(1)->first();
This works, but I do not know if it is the right way to go.
It seems neither the Username or Email columns are unique, this can cause two accounts of the same username or email to be created. Not sure if this was intentional but I would suggest at least one or both of these fields be required to be unique.
Verify library assumes that you have checked for logged in user before using the role checking and returns false even if the user is logged in and has that role.
Example: I had a view that add's functionality based on role but visitor doesnt have to be logged in so there's no Auth::check()
, Auth::guest()
etc. used before using Auth::is('Role name')
check.
I fixed this by adding the check to the private function get_user($user = NULL) method:
Replace this:
$user = $this->user;
..with this:
if ($this->check())
{
$user = $this->user;
}
else
{
$user = NULL;
}
With this the user gets initialized/populated if visitor is logged in.
Why the "Auth::retrieve" don't retrieve the logged user without passing id?
I much more simple to use this method.
Sorry, my English is horrible.
In the database's users table there is fieldname "confirmed" but Verify library is looking for "verified" fieldname. Fix is to either change the schema "confirmed" -> "verified" field or change the "verified" to "confirmed" in the Verify library.
My User model extends Verify\Models\User, and most everything is working awesome. Thanks for this bundle.
One issue I have is when I try to run an update on the user (i.e. changing the password) everything seems to work fine, but the password is not getting hashed or salted, it is just inserted as plain text.
User::where_id(Input::get('user_id'))
->update(array(
'password' => Input::get('password'),
'updated_at' => date('Y-m-d g:i:s'),
));
Time columns can't be null:
DB::table(VERIFY_PREFIX.'roles')->insert(array(
'name' => Config::get('verify::verify.super_admin'),
'level' => 10,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
));
DB::table(VERIFY_PREFIX.'users')->insert(array(
'username' => 'admin',
'password' => '$2a$08$rqN6idpy0FwezH72fQcdqunbJp7GJVm8j94atsTOqCeuNvc3PzH3m',
'salt' => 'a227383075861e775d0af6281ea05a49',
'role_id' => 1,
'email' => '[email protected]',
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s')
));
php artisan bundle:install verify
Successfully Installed!php artisan migrate verify
string(58) "SELECTname
FROMlaravel_migrations
WHEREbundle
= ?"
No outstanding migrations.
The install script doesn't register the migration into the database.
Just created a fresh and clean Laravel installation and installed the verify bundle.
However if i migrate verify the response is;
SQLSTATE[HY000]: General error: 1005 Can't create table 'mydb.#sql-3e3_e0' (errno: 150)
SQL: ALTER TABLE users
ADD CONSTRAINT users_role_id_foreign FOREIGN KEY (role_id
) REFERENCES roles
(id
)
My own migration work great, so i guess something is 'broken'?
Hi,
I am expanding the User
class of Verify to make some changes for my project.
I want to access a model that I have, named Project
.
Which namespace do I need to use? It's in the default application/models
folder.
When running the migrate command in artisan, a sql error is thrown
ALTER TABLE "users" ADD CONSTRAINT users_role_id_foreign FOREIGN KEY ("role_id") REFERENCES "roles" ("id")
According to the SQLite docs, only RENAME TABLE and ADD COLUMN are supported for the ALTER TABLE command.
Running the migrate command returns
$ php artisan migrate verify
SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "description" violates not-null constraint
SQL: INSERT INTO "roles" ("name", "level") VALUES (?, ?)
Bindings: array (
0 => 'Super Admin',
1 => 10,
)
While installing in a blank MySQL database called 'demo' :
$ php artisan migrate verify
SQLSTATE[HY000]: General error: 1005 Can't create table 'demo.#sql-3bf_30' (errno: 150)
SQL: ALTER TABLE users
ADD CONSTRAINT users_role_id_foreign FOREIGN KEY (role_id
) REFERENCES roles
(id
)
Bindings: array (
)
SQLSTATE[HY000]: General error: 1005 Can't create table 'verify-auth.#sql-920_4f
1' (errno: 150)
SQL: ALTER TABLE users
ADD CONSTRAINT users_role_id_foreign FOREIGN KEY (role _id
) REFERENCES roles
(id
)
Bindings: array (
)
Hi,
I have a model, and I have this function:
<?php
class Ticketentry extends Eloquent {
public function ticket()
{
return $this->has_one('Ticket');
}
public function user()
{
return $this->has_one('Verify\Models\User','id');
}
}
Yet, when I grab a Ticketentry, and I try to do $ticketentry->user->username
, it doesn't work. What am I doing wrong?
I get this error:
Trying to get property of non-object
Hello!
Give please a form view and controler example for work with Verify.
Thanks!
Hi,
How do i use Verify in a task? Verify\Models\User::where(args) doesnt work, because it couldnt find the class.
@Toddish A feature request:
Could there be some sort of config setting added that would allow to prefix the db_tables?
On a big project it would make it clearer which tables are from what.
Installing on a blank sqlite3 database....
$ php artisan migrate verify
SQLSTATE[HY000]: General error: 1 near "CONSTRAINT": syntax error
SQL: ALTER TABLE "users" ADD CONSTRAINT users_role_id_foreign FOREIGN KEY ("role
_id") REFERENCES "roles" ("id")
Bindings: array (
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.