Skip to content
Discussion options

You must be logged in to vote

I did this 👇 as a RPC function

create or replace function change_user_password(current_plain_password varchar, new_plain_password varchar)
returns json
language plpgsql
security definer
as $$
DECLARE
_uid uuid; -- for checking by 'is not found'
user_id uuid; -- to store the user id from the request
BEGIN
  -- First of all check the new password rules
  -- not empty
  IF (new_plain_password = '') IS NOT FALSE THEN
    RAISE EXCEPTION 'new password is empty';
  -- minimum 6 chars
  ELSIF char_length(new_plain_password) < 6 THEN
    RAISE EXCEPTION 'it must be at least 6 characters in length';
  END IF;
  
  -- Get user by his current auth.uid and current password
  user_id := auth.uid();
  S…

Replies: 14 comments 27 replies

Comment options

You must be logged in to vote
1 reply
@zakaria-chahboun
Comment options

Comment options

You must be logged in to vote
8 replies
@zakaria-chahboun
Comment options

@seho0808
Comment options

@olaberglund
Comment options

@cenullum
Comment options

@Tranthanh98
Comment options

Answer selected by zakaria-chahboun
Comment options

You must be logged in to vote
1 reply
@zakaria-chahboun
Comment options

Comment options

You must be logged in to vote
2 replies
@zakaria-chahboun
Comment options

@GaryAustin1
Comment options

Comment options

You must be logged in to vote
5 replies
@zakaria-chahboun
Comment options

@GaryAustin1
Comment options

@GaryAustin1
Comment options

@zakaria-chahboun
Comment options

@GaryAustin1
Comment options

Comment options

You must be logged in to vote
4 replies
@gauravkaliadev
Comment options

@gauravkaliadev
Comment options

@kei-kusanagi
Comment options

@gauravkaliadev
Comment options

Comment options

You must be logged in to vote
3 replies
@Sisableng
Comment options

@STIAANWOL
Comment options

@Sisableng
Comment options

Comment options

You must be logged in to vote
2 replies
@nmerchant
Comment options

@josiext
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@olaberglund
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet