parsav  Diff

Differences From Artifact [f0f9593494]:

To Artifact [0f1425913d]:


   215    215   			insert into parsav_auth (uid, name, kind, cred) values (
   216    216   				$1::bigint,
   217    217   				(select handle from parsav_actors where id = $1::bigint),
   218    218   				'pw-sha256', $2::bytea
   219    219   			)
   220    220   		]]
   221    221   	};
          222  +
          223  +	auth_purge_type = {
          224  +		params = {rawstring, uint64, rawstring}, cmd = true, sql = [[
          225  +			delete from parsav_auth where
          226  +				((uid = 0 and name = $1::text) or uid = $2::bigint) and
          227  +				kind like $3::text
          228  +		]]
          229  +	};
   222    230   
   223    231   	post_create = {
   224    232   		params = {uint64, rawstring, rawstring, rawstring}, sql = [[
   225    233   			insert into parsav_posts (
   226    234   				author, subject, acl, body,
   227    235   				posted, discovered,
   228    236   				circles, mentions
................................................................................
   876    884   
   877    885   	auth_create_pw = [terra(
   878    886   		src: &lib.store.source,
   879    887   		uid: uint64,
   880    888   		reset: bool,
   881    889   		pw: lib.mem.ptr(int8)
   882    890   	): {}
   883         -		-- TODO impl reset support
   884    891   		var hash: uint8[lib.crypt.algsz.sha256]
   885    892   		if lib.md.mbedtls_md(lib.md.mbedtls_md_info_from_type(lib.crypt.alg.sha256.id),
   886    893   			[&uint8](pw.ptr), pw.ct, &hash[0]) ~= 0 then
   887    894   			lib.bail('cannot hash password')
   888    895   		end
          896  +		if reset then queries.auth_purge_type.exec(src, nil, uid, 'pw-%') end
   889    897   		queries.auth_create_pw.exec(src, uid, [lib.mem.ptr(uint8)] {ptr = &hash[0], ct = [hash.type.N]})
   890    898   	end];
          899  +
          900  +	auth_purge_pw = [terra(src: &lib.store.source, uid: uint64, handle: rawstring): {}
          901  +		queries.auth_purge_type.exec(src, handle, uid, 'pw-%')
          902  +	end];
          903  +
          904  +	auth_purge_otp = [terra(src: &lib.store.source, uid: uint64, handle: rawstring): {}
          905  +		queries.auth_purge_type.exec(src, handle, uid, 'otp-%')
          906  +	end];
          907  +
          908  +	auth_purge_trust = [terra(src: &lib.store.source, uid: uint64, handle: rawstring): {}
          909  +		queries.auth_purge_type.exec(src, handle, uid, 'trust')
          910  +	end];
   891    911   
   892    912   	actor_auth_register_uid = nil; -- not necessary for view-based auth
   893    913   
   894    914   }
   895    915   
   896    916   return b