Create an invitation link using django rest framework?

71 views
Skip to first unread message

Pradyum Gupta

unread,
Sep 21, 2020, 10:15:33 AM9/21/20
to Django REST framework

am looking for some advice/Mentorship.

wanted to create an invitation link for onboarding user to a company similarly slack does by sending company employees email so that they could directly join the company but using the Django rest framework is there any method that you can refer?

see things that I have in my mind coming is that I can put company_id in hash inside a link and then when a user will come with that hash I can compare it and onboard the user.

but in that case, there is no link_time_age I can compare!

is there any method or any crypto algo in which is can convert company_UUID into some string and decode back into UUID and then compare it through icontains and similarly I can do with time and age of link?

but first of all, is this the right approach? or how do people in a company like slack or telegram do?

any kind of help will be really appreciated.

See what am looking for certain guidance or any reference documentation.

Matemática A3K

unread,
Sep 23, 2020, 2:38:45 AM9/23/20
to django-res...@googlegroups.com
On Mon, Sep 21, 2020 at 9:15 AM Pradyum Gupta <prad...@gmail.com> wrote:

am looking for some advice/Mentorship.

wanted to create an invitation link for onboarding user to a company similarly slack does by sending company employees email so that they could directly join the company but using the Django rest framework is there any method that you can refer?

see things that I have in my mind coming is that I can put company_id in hash inside a link and then when a user will come with that hash I can compare it and onboard the user. 

but in that case, there is no link_time_age I can compare!

You can generate a hash and store a timestamp in the model (Django model), then code the logic you are referring in the view (you get the model instance through the hash)

is there any method or any crypto algo in which is can convert company_UUID into some string and decode back into UUID and then compare it through icontains

There is, see Django's PasswordResetView - although you may not need it

and similarly I can do with time and age of link?

IMO, it would be easier for you to store that in a model and write the logic than encapsulate all the info in a hash

but first of all, is this the right approach?

Both get the job done, both have their own advantages, is up to you to decide in terms of benefits and costs (i.e. complexity)

or how do people in a company like slack or telegram do?

I don't know if people working there can answer that (at least shortly: https://whimsical.com/P53PjXCBWEi2fdMjP2Hti)

any kind of help will be really appreciated.

See what am looking for certain guidance or any reference documentation.

 
Hope that helps getting your way through it

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/5cec683f-45d8-4259-a992-0a20f2f3053an%40googlegroups.com.

naveen Kumar

unread,
Sep 23, 2020, 2:42:57 AM9/23/20
to django-res...@googlegroups.com
class TokenGenerator(PasswordResetTokenGenerator):

  def _make_hash_value(self, user, timestamp):
    return (
              six.text_type(user.pk) + six.text_type(timestamp) +
              six.text_type(user.username)  )


account_activation_token = TokenGenerator()

follow this you can hash both values company, time_age

--

Pradyum Gupta

unread,
Sep 24, 2020, 3:48:27 AM9/24/20
to django-res...@googlegroups.com
Thank you 

@Naveen Kumar and @Matemática A3K


Will try both the options.

Regards
Pradyum


You received this message because you are subscribed to a topic in the Google Groups "Django REST framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-rest-framework/ZBYxC2pEn7Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/CAN9FMSwjSDnfk1HgvjVBwqtSizb79NSWo36aSwiuDfJ-DR7Yhg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages