dbo.backend_datos_user

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

5
Name Data Type Length Description
@p_cliente int 4
@p_cli_codigo int 4
@p_username varchar 60
@p_email varchar 100
@p_login_mail char 1

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO

CREATE OR ALTER PROCEDURE dbo.backend_datos_user
@p_cliente int, 
@p_cli_codigo int, 
@p_username varchar(60), 
@p_email varchar(100),
@p_login_mail char(1) = 'L'

AS
BEGIN
 
    SET NOCOUNT ON;

if @p_login_mail = 'L' 
begin
 
 
 begin
  if ((select count(*) 
     from users
    inner join clientes_usuarios
       on clientes_usuarios.user_id = users.user_id
    where lower(users.username) = lower(@p_username)
    and cliente != @p_cliente) > 0 
    or 
  (select count(*) 
     from users 
    where lower(users.username) = lower(@p_username)
    and cli_codigo != @p_cli_codigo) > 0 )

  begin
     select '1' as error, 'Ese login es de otro cliente ffff' as mensaje, 
      '' as username, '' as email, '' as first_name, '' as last_name, '' as password
  end 

  else

  begin
     select '0' as error, '' as mensaje,
      lower(users.username) as username, 
         lower(users.email) as email, 
      users.first_name,
      users.last_name,
      users.password
     from users
    where lower(users.username) = lower(@p_username)
  end 

 end
end

else

begin
/*
if (select count(*) 
   from users 
  where lower(users.email) = lower(@p_email)
    and cli_codigo != @p_cli_codigo
and lower(users.username) != lower(@p_username)) > 0 
*/

 if ((select count(*) 
     from users
    inner join clientes_usuarios
       on clientes_usuarios.user_id = users.user_id
    where lower(users.email) = lower(@p_email)
    and cliente != @p_cliente) > 0 
    or 
  (select count(*) 
     from users 
    where lower(users.email) = lower(@p_email)
    and cli_codigo != @p_cli_codigo) > 0 )


   
  begin
     select '1' as error, 'Ese mail es de otro usuario' as mensaje, 
      '' as email
  end 

  else 
   

  begin
     select '0' as error, '' as mensaje, 
      lower(@p_email) as email
  end 
end 

END

GO

Used By

No items found