umputun / remark42

comment engine
https://remark42.com
MIT License
4.9k stars 381 forks source link

Verified status for users #60

Closed umputun closed 6 years ago

umputun commented 6 years ago

The goal is to provide a way to set/rest "Verified" status for any user. It is going to be admin-only rest call and this info will be propagated to user's token and will be part of any user sub-struct in responses.

On UI side verified will be shown near username as some little badge and it will need a way for admin part of UI to set/reset this status.

cc @igoradamenko

umputun commented 6 years ago
  1. in order to support verified status via auth/jwt we need info about the site. I have added an optional parameter site to /login controller.
  2. New method PUT /api/v1/admin/verify/{userid}?site=site-id&verified=1 to set/reset verified status
  3. User struct extended with verified flag
igoradamenko commented 6 years ago

@umputun, I've added verify check icon to comment component, but I don't see verified flag in User struct.

For instance, I send request for verification

https://demo.remark42.com/api/v1/admin/verify/github_ef0f706a79cc24b17bbbb374cd234a691d034128?verified=1&site=remark

and get this response:

{"user":"github_ef0f706a79cc24b17bbbb374cd234a691d034128","verified":true}

But then I request comment of user github_ef0f706a79cc24b17bbbb374cd234a691d034128 and get this struct:

{
    "id":"06c9cf5d-a78b-4886-9f39-65dbbfe7de72",
    "pid":"5bccdac8-9825-4492-abba-4c8b854d8e68",
    "text":"<p>это часть другого виджета и решение показывать count или нет на стороне того, кто этот виджет добавляет <a href=\"https://github.com/umputun/remark#counter\" rel=\"nofollow\">https://github.com/umputun/remark#counter</a></p>\n",
    "orig":"это часть другого виджета и решение показывать count или нет на стороне того, кто этот виджет добавляет https://github.com/umputun/remark#counter",
    "user":{
        "name":"Umputun",
        "id":"github_ef0f706a79cc24b17bbbb374cd234a691d034128",
        "picture":"https://demo.remark42.com/api/v1/avatar/cb42ff493ade696d88a3a590f136ae9e34de7c1b.image",
        "ip":"b02b9c00b7dc8c936f3acd4c6764317fecf25960",
        "admin":true
    },
    "locator":{
        "site":"remark",
        "url":"https://remark42.com/demo/"
    },
    "score":0,
    "votes":{

    },
    "time":"2018-06-10T16:15:55.339450054-05:00"
}

As you see there is no verified flag in user object. What do I do wrong?

umputun commented 6 years ago

The reason for this was lack of retroactive verified status. In other words, only new comments created for the user with verified status had this flag populated. I have added this flag to alterComments processing response before it sent to a client and this should do it.

igoradamenko commented 6 years ago

Now it works, thanks!