Comments (19)
USER_PASS
? is it hashed? I think you are using an existing users table and the password is not hashed.
from laravel-oci8.
Hi,
Are you using blob field on your user table? If not, then just use Model/Eloquent directly. I only use OracleEloquent for blob fields.
from laravel-oci8.
Yeah I was using OracleElequent, then tried Model, did authenticate but still lost after new page request. Here is my model code, then the Auth snippet.
<?php namespace App;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use App\RoleModel;
class UserModel extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
use Permission;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'USER';
public $primaryKey = 'USER_SERNO';
/**
* The attributes that are mass assignable.
*
* @var array
*/
// protected $fillable = ['username', 'email', 'password'];
// public $guarded = ['role_id'];
public $guarded = [];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
public function setPasswordAttribute( $password ) {
$this->attributes['password'] = \Hash::make( $password );
}
}
Auth snippet:
if (Auth::attempt(['email' => $email, 'password' => $password]))
{
$user = Auth::user(); // had to do this to get it to work
session(['user' => $user ] ); // had to do this to get it to work
from laravel-oci8.
You're using class UserModel extends Model
which is Laravel's default model. It should work as expected. Have you tried using the default AuthController
of Laravel?
FYI: The package have use yajra\Oci8\Eloquent\OracleEloquent as Eloquent;
class which was what I thought you were referring to. OracleEloquent
.
from laravel-oci8.
I will try using laravel's AuthController sure, although used same code with MySQL db driver and works fine.
Regarding OracleEloquent, I keep it OracleElequent just so I won't be confused, but thanks for mentioning :)
//basically all other models extend this
use yajra\Oci8\Eloquent\OracleEloquent as OracleElequent;
class BaseModel extends OracleElequent {
from laravel-oci8.
Hello,
I tried Laravel's built in Auth controller, registering fine, and after registering session is stored, so that's working.
Login in, same problem, Auth user is only stored for that page request. New page requests it's lost.
I tried dd (Auth::user) when register and logging in. Identical, just why is the logging in isn't being stored in session. Is driving me crazy.
Also tried the exact function in register method: Auth::login($user); Doesn't working when logging in.
Any hints or where to debug? I would live to print the session values, but not sure how to do that in Laravel, because it's not php $_SESSION.
from laravel-oci8.
After some debugging, and Using Session::all()
the login token is empty in case of user logging in, below:
array:5 [▼ "_token" => "HrSjpH8S8dgu0FGGTzN8GQIjr4G98JFLb9xSJrgk" "_previous" => array:1 [▶] "flash" => array:2 [▶] "login_82e5d2c56bdd0811318f0cf078b78bfc" => null "flash_message" => "welcome in" ]
In case of user registering, it has the user ID
"login_82e5d2c56bdd0811318f0cf078b78bfc" => 132
No clue why this only happens with Oracle, using MySQL is fine, and it's a session file in both cases !
But thanks mate, as I said I had a workaround, so it's not urgent. But would love to hear your thoughts, and if you are as persistent as I am, I can give you FTP access to development server to further look into it.
from laravel-oci8.
Totally figured out what's wrong, although it took hours of debugging!
When creating a user model, it works perfectly, then Auth::login($user) works fine.
When retrieving $user model, using Auth::attempt or fetching user by email then Hash::check passwords, the user primary key (user ID), is stored in Laravel model as small case, user_id, doesn't work. When creating it's stored in Laravel model in capital case, USER_ID.
Anyways so when logging in, laravel is confused and doesn't find the id, so login is only for 1 page request. Then token_***** is stored NULL.
All good now, I finally fixed it, just when logging in, I get user by email, then manually set the id to capital case, then send the model object to Auth::login. I bet I can find a way to do all of that using Model's setters and geters, this way it's in one location, not doing it whenever I need to login.
Damn it Oracles, why the hell are you confusing me!
Feel free to close this issue when you like. But out of curiosity, how is it working with you! Auth::attemp ? we must be on different Oracle server/client/configurations.
Thanks again, see ya.
from laravel-oci8.
Hi, good to know you were able to fixed this issue. I haven't encountered this yet but maybe this occurs because you specifically use upper case value on table
and primaryKey
on your model (will also check if that might cause the issue on my free time)? Oracle is a bit hard on us when it comes to text case like on sorting, searching, etc..
from laravel-oci8.
Hi, I was able to replicate this issue just now by setting protected $primaryKey = 'ID';
in my model. You can fix this issue by using small case id protected $primaryKey = 'id';
. Thanks for the hints.
Note: the package converts all fields name to small case which may have cause the confusion.
from laravel-oci8.
oh great, what I ended up doing was override Elequent's get primary key function, but will try check out your suggestion.
public function getKeyName()
{
$this->ID = $this->id;
return $this->primaryKey ;
}
from laravel-oci8.
Hi
I faced with a big problem for login to system .
when i register a new user -> this is Ok and after register immediately login to system .
but when i logout and want to login to system by attempt function this returned an error .
how i manage login ?
Thank you
from laravel-oci8.
User Model is :
class User extends Authenticatable
{
use Notifiable;
public $sequence = 'user_id_seq';
protected $table = 'USERS';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'FULLNAME', 'USERNAME', 'EMAIL', 'USER_PASS', 'IS_ADMIN', 'ACTIVE'
, 'IS_SUPERADMIN'
];
}
Login Function is :
public function getLogin(Request $request)
{
$username = $request->get('username');
$pass = $request->get('password');
if (Auth::attempt(['USERNAME' => $username, 'USER_PASS' => $pass])) {
dd('yes');
} else {
dd('no');
}
}
This return no ,
anyone know answer ?
Thank you
from laravel-oci8.
@yajra
@AminMkh
You know how i can solve this error?
from laravel-oci8.
i do all steps for add OracleServiceProvider to Providers/AuthServiceProvider.php class :
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
Auth::provider('oracle', function ($app, array $config) {
return new \Yajra\Oci8\Auth\OracleUserProvider($app['hash'], $config['model']);
});
$this->registerPolicies();
}
}
and change login function :
$username = $request->get('username');
$pass = $request->get('password');
$creadentials = ['USERNAME'=> $username , 'USER_PASS'=>$pass];
dd(Auth::retrieveByCredentials($creadentials));
but i see this error after login :
Symfony\Component\Debug\Exception\FatalThrowableError in AuthManager.php line 294:
Call to undefined method Illuminate\Auth\SessionGuard::retrieveByCredentials()
from laravel-oci8.
@yajra : PLEASE HELP ME
from laravel-oci8.
@ali2535 see docs https://github.com/yajra/laravel-oci8#laravel-52-oracle-user-provider
To use, just update
auth.php
config and set the driver to oracle
'providers' => [
'users' => [
'driver' => 'oracle',
'model' => App\User::class,
],
]
from laravel-oci8.
@yajra :
Thank you for your answer .
i do this . but this no change . i get same error .
yajra can you give me an example from scratch that show login function?
what is the problem for my login code ?
from laravel-oci8.
i change the code :
dd(Auth::attempt('USERNAME'=> $username , 'USER_PASS'=>$pass);
but this always return false . why ?
from laravel-oci8.
Related Issues (20)
- Updating model with multiple blob columns fails
- DRCP Connection Pooling HOT 4
- Undefined type 'Yajra\Oci8\Oci8ServiceProvider'. HOT 5
- Method Yajra\Oci8\Schema\Grammars\OracleGrammar::compileColumns does not exist. HOT 2
- v10.4.3 introduced SQL error in SELECT FOR UPDATE HOT 4
- OracleProcessor.php function processColumns donot return key "auto_increment" HOT 2
- OCI_SUCCESS_WITH_INFO: ORA-28002: the password will expire within 13 days HOT 2
- Laravel 11 support is on the road? HOT 5
- [11.x] This database engine does not support inserting while ignoring errors.
- [11.x] Error Code : 942 Error Message : ORA-00942, Sessions table HOT 1
- Support PHP 8.3 With Laravel 10.x HOT 1
- Error LogicException This database driver does not support modifying columns HOT 1
- `Schema::dropIfExists()` not working in 11.2.2+ HOT 2
- Upgrading laravel/framework v11.15.0 fails migration containing table update (ORA-01430) HOT 1
- Problem with sequence with long table name HOT 1
- Improving pagination performance HOT 5
- Order "compileColumnExists" by column_id HOT 1
- Problem with "wrapTable" function using it in "compileUpsert" HOT 1
- Lock for update implementation on 9x HOT 3
- Problem with ORM update HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-oci8.