Serenity: Autorization (UserId)

Created on 18 Jul 2018  路  4Comments  路  Source: serenity-is/Serenity

I have the following code on my system for quite some time, after upgrading to StartSharp it is no longer working.
@volkanceylan , how do I get the UserId on the client side?

 private permiteAlteracao(note: NoteRow) {
            if (note.InsertUserId != Authorization.userDefinition.UserId) {
                Q.alert("Ops! N茫o 茅 poss铆vel alterar ou excluir anota莽茫o de outro usu谩rio!");
                return false;
            }

            return true;
        }

image

Most helpful comment

Update your class ScriptUserDefinition.cs
Add a new property UserId into it.
Update your function public ScriptUserDefinition GetUserData()
Assign the UserId value from UserDefinition.Id into that new property

All 4 comments

Update your class ScriptUserDefinition.cs
Add a new property UserId into it.
Update your function public ScriptUserDefinition GetUserData()
Assign the UserId value from UserDefinition.Id into that new property

@Febriantos, I thought about it, but why did @volkanceylan remove it?
Is this what I want to do differently?
If I add this property again, will it go wrong at another point in the system?

You should perform such checks at repository, not client side. Don't depend on any clientside information.

Hi @adalberto-argente

For checks I agree with Volkan - only on the server side you have full control.

But there are other scenarios - e.g. when using the CloneEntity on client-side and you want to set for example who has done the cloning directly while cloning - then you want to have the user Id on client-side and in such a scenario, @Febriantos suggestion makes much sense.

With kind regards,

John

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moostafaa picture moostafaa  路  3Comments

stixoffire picture stixoffire  路  3Comments

Akarsh03 picture Akarsh03  路  3Comments

newyearsoft picture newyearsoft  路  3Comments

AmuthaKondusamy picture AmuthaKondusamy  路  3Comments