Meteor errors internationalization - internationalization

I'm trying to implement internationalization through just-i18n and it works fine so far.
Problem is I'm also using accounts-password and especially Meteor.loginWithPassword(user, password, [callback]).
On login error, the callback has an error object that basically looks like this :
{
details: undefined,
error: 403,
errorType: "Meteor.Error",
message: "User not found [403]",
reason: "User not found"
}
I thought the error code was unique and went with a i18n configuration file like this :
i18n.map 'fr_FR',
login:
signin: 'S\'authentifier'
errors:
403: 'L\'utilisateur n\'existe pas'
So I could call it this way :
Session.set "error", i18n("errors." + err.error)
But actually, no matter what's the error, user not found or incorrect password, the error code is not unique :
{
details: undefined,
error: 403,
errorType: "Meteor.Error",
message: "Incorrect password [403]",
reason: "Incorrect password"
}
As i don't consider checking on a string value really consistent, how can i differenciate both ?
How would I go implementing internationalization with meteor built-in login ?

403 here is not a Meteor number for the particular error, but rather a HTTP status code. The same code can be caused by different errors.
Since the only difference between the error objects you get are reason and message, you need to use one of them to set up the internationalization code. They shouldn't change too much between Meteor releases, so you should be fine with this solution.
i18n.map 'fr_FR',
login:
signin: 'S\'authentifier'
errors:
403:
'Incorrect password': 'Le password est incorrectu'
'User not found': 'L\'utilisateur n\'existe pas'
Ah, and don't worry, login, signin, errors and 403 are internally represented as strings as well, so there's nothing inconsistent in such solution.

Related

Error <52>: ldap_simple_bind_s() failed: Unavailable

When i am trying to use simple bind to connect to Active Directory using LDAP protocol, i am getting following error:
res = ldap_simple_bind_s(ld, 'CN=test,CN=Users,DC=domain,DC=com', <unavailable>); // v.3
Error <52>: ldap_simple_bind_s() failed: Unavailable
Server error: 80090304: LdapErr: DSID-0C09044E, comment: AcceptSecurityContext error, data 20ee, v2580
Error 0x80090304 The Local Security Authority cannot be contacted
the username i am using is = CN=test,CN=Users,DC=domain,DC=com
Please let me know how to resolve this issue. also let me know if any other info. required. Thank you :)
The data value gives you the Windows Error Code. If you look that up in the documentation, it's this:
ERROR_DS_INTERNAL_FAILURE
8430 (0x20EE)
The directory service encountered an internal failure.
I can't tell you exactly what that means, but it looks like something wrong with the domain controller.

Change default Laravel "Server error" message

I've noticed that in production mode with my debug mode set to false that most of my functions that have a try/catch will return the Laravel default "Server error" message.
I've been trying to hunt this message down with little luck, how can I customise this generic message returned from functions within my Laravel app whilst debug is turned off?
If you're referring to a very generic HTTP 500 error, it's a blade file in the framework.
If you want to display your own error for 5XX errors and such, you can override them by creating a blade file with the name of the error you want to override. For example:
resources/views/errors/500.blade.php
{{ __('Uh oh. Something has gone wrong behind the scenes.');
Now when a 500 error is encountered, your blade error will be displayed rather than the default Laravel 500 error.
You can create files for the common errors too obviously.
Update
The default messages for HTTPExceptions in Laravel are provided by the Symfony Response class found in the Symfony\Component\HttpFoundation directory.
When it comes to providing error messages in APIs, most will send the default HTTP status code in the headers and then supply a human error message in the response body.
For your example you might do something like:
return response()->json([
'errors' => [
[
'status' => 500,
'title' => 'Internal server error',
'message' => 'A more detailed error message to show the end user'
],
]
], 500);
You would then be responsible for consuming the error response and showing the end user the human readable error rather than the default generic Internal server error.
You might find some of the JSON API examples useful.
In my case, my Model extends Authenticable.
I changed it to Model and imported Eloquence.

Accessing API layer

I am trying to access an api function, for example I want to access the login function, I get the following error:
"message": "An internal error occurred during your request!",
Looking in the log file, the following log is there:
ERROR 2017-10-09 17:01:37,296 [11 ]
nHandling.AbpApiExceptionFilterAttribute - Processing of the HTTP
request resulted in an exception. Please see the HTTP response
returned by the 'Response' property of this exception for details.
System.Web.Http.HttpResponseException: Processing of the HTTP request
resulted in an exception. Please see the HTTP response returned by the
'Response' property of this exception for details.
I am using Postman to test. My URL is https://localhost:44347/api/Account/Authenticate. My header has Context-Type as "application/json" and in my Body I have the loginModel formatted as
{
"tenancyName": "tenantname",
"userNameOrEmailAddress": "admin",
"password": "123qwe"
}
Am not sure how else to proceed on this. Any ideas please? I have swagger installed as well.
I am using MVC + AngularJS template. I have not changed anything, just the default project.
Appreciate the assistance.
I have tested with Fiddler and it works correctly.
Note: make sure you type Content-Type correctly, on the question you typed Context-Type
Make a POST request! You may be missing this.

How to Log Laravel 404 Error With Details

Just as in the title, I am getting a 404 error in my Log but don't know where/why this error is happening cause my App is working fine without a problem.
Is there a way for me to log the error in details (the referral link) e.g
Error
[2014-11-30 05:44:13] production.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /home/domain/laravel/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php:146
Details
Detail: User tried to access route http://domain.com/users
Thanks, any help will be appreciated.
App::missing(function($exception)
{
Log::error( Request::url() );
return Response::view('errors.missing', array(), 404);
});
or use Request::fullUrl() this includes query strings in the URL
You need to make the view.

Zend\Authentication\Storage\Session Session validation failed, any ideas?

I have a simple authentication code like on a zf2 application
$this->auth = new AuthenticationService(new Session($this->namespace));
and the external modules used are
ZendDeveloperTools
BjyProfiler
Everytime, I try to authenticate, like
$this->auth->authenticate($adapter)
I get a "Session validation failed" error message.
When I disable ZendDeveloperTools module, I do not get this error but couldnot fix. I also checked Zend\Session\Container Session validation failed exception — Object(Closure) ZF2, but I do not have anywhere on my code
$sharedEvents->attach('', '', .. )
as suggested by Crisp
i had a same problem.
Look at:
ZendDeveloperTools/Listener/EventLoggingListenerAggregate.php Line: 64
$events->attach($this->identifiers, '*', array($this,'onCollectEvent'),
Profiler::PRIORITY_EVENT_COLLECTOR);
i uncomment it, then i don't get the error.
Hope it was helpful.

Resources