You are not logged in.
Pages: 1
Hi, I'm trying to change a password of the current user using a Interface based service.
function TServiceSQLExec.ChangePassword(aPass : RawUTF8) : RawJSON;
var
Ctxt : TServiceRunningContext;
AuthUser : TSQLAuthUser;
Rest : TSQLRestServerFullMemory;
begin
Ctxt := CurrentServiceContext;
Rest := Ctxt.Request.Server as TSQLRestServerFullMemory;
AuthUser := Rest.SessionGetUser(Ctxt.Request.Session);
AuthUser.PasswordPlain := aPass;
Rest.Update(AuthUser);
Rest.UpdateToFile;
end;
It saves the password OK but it saves the GroupRights field equal to 0 instead of 3. I'm using TSQLRestServerFullMemory and a JSON file for user registration like sample 16.
What am I doing wrong?
Thanks in advance,
Al
Offline
As stated by the doc, SessionGetUser() does not retrieve the full User() content, but makes a copy of the value in memory.
Solution is not to use this SessionGetUser() method to retrieve the member, but load AuthUser from the ORM via AuthUser.Create(Rest,ID).
Offline
Hi ab, first of all Marry Christmas, second, it works perfect, thank you and third, when debugging the server I got this exception in case of time-out or if the client close the connection:
20131227 02492900 EXC EHttpApiServer ("HttpSendHttpResponse failed: An operati
on was attempted on a nonexistent network connection (1229)") at 006C97D2 stack
trace 0045B1BD 00408B26 762A336A 77379F72 77379F45
I got 2 others access violations, it is very simple to reproduce, just start debugging and have a coffee or smoke a cigarette.
Thanks in advance and merry Christmas again.
Al
Offline
Now THttpApiServer won't try to send an error message when connection is broken.
See http://synopse.info/fossil/info/395b247710
Offline
Unfortunately, I still get these exceptions when stepping through my server code and it doesn't take more than 10, 15 secs to have the exception raised.
I downloaded a Nightly Build today.
fpcdeluxe, FPC 3.2 / Lazarus 2.0, mORMot on Windows 10 ...
Offline
Hi ab, a regular access violation, I can send you a print screen if you want but it is a "pretty regular" access violation. By the way, what is the best place to catch EHttpApiServer exception? It is raised after the method is completed.
Regards,
AL
Offline
Hi, logging is enabled and verbose and .map file or {$D+} is active but no stack is returned in the log because the Access Violation is raised inside procedure AddStackManual(Stack: PPtrUInt); ( Of course if you disable logging no Access Violation is raised )
in line
while (PtrUInt(stack)<max_stack) do begin
st := stack^;
if ((st>max_stack) or (st<min_stack)) and <------ Exception is here
not IsBadReadPtr(pointer(st-8),12) and
((pByte(st-5)^=$E8) or check2(st)) then begin
TSynMapFile.Log(fWriter,st); // will ignore any TSynLog.* methods
dec(depth);
if depth=0 then break;
end;
inc(stack);
end;
except
// just ignore any access violation here
end;
The console LOG is:
20131231 03130315 srvr TSQLRestServerFullMemory(0575B170) POST MySQLExe
c.ChangePassword -> 200
20131231 03130315 - TSQLRestServerFullMemory(0575B170). 77.034.233
20131231 03141752 EXC EHttpApiServer ("HttpSendHttpResponse failed: An operati
on was attempted on a nonexistent network connection (1229)") at 007DE63E stack
trace 00475925 00408E72 00639D4C 00528E99 7564336A 774A9F72 774A9F45
Last edited by foncci (2013-12-31 07:57:52)
Offline
Pages: 1