forked from EVOgeek/Vmeda.Online
		
	MOBILE-3948 h5p: User uniqueness by id instead of email
This commit is contained in:
		
							parent
							
								
									4ec6096482
								
							
						
					
					
						commit
						8f4b2df43a
					
				| @ -52,4 +52,45 @@ H5P.getMoodleComponent = function () { | |||||||
|         return H5PIntegration.moodleComponent; |         return H5PIntegration.moodleComponent; | ||||||
|     } |     } | ||||||
|     return undefined; |     return undefined; | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Set the actor. (Moved to overrides due to MDL-69467) | ||||||
|  |  */ | ||||||
|  |  H5P.XAPIEvent.prototype.setActor = function () { | ||||||
|  |     if (H5PIntegration.user !== undefined) { | ||||||
|  |         this.data.statement.actor = { | ||||||
|  |             'name': H5PIntegration.user.name, | ||||||
|  |             'objectType': 'Agent' | ||||||
|  |         }; | ||||||
|  |         if (H5PIntegration.user.id !== undefined) { | ||||||
|  |             this.data.statement.actor.account = { | ||||||
|  |                 'name': H5PIntegration.user.id, | ||||||
|  |                 'homePage': H5PIntegration.siteUrl | ||||||
|  |             } | ||||||
|  |         } else if (H5PIntegration.user.mail !== undefined) { | ||||||
|  |             this.data.statement.actor.mbox = 'mailto:' + H5PIntegration.user.mail; | ||||||
|  |         } | ||||||
|  |     } else { | ||||||
|  |         var uuid; | ||||||
|  |         try { | ||||||
|  |             if (localStorage.H5PUserUUID) { | ||||||
|  |                 uuid = localStorage.H5PUserUUID; | ||||||
|  |             } else { | ||||||
|  |                 uuid = H5P.createUUID(); | ||||||
|  |                 localStorage.H5PUserUUID = uuid; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         catch (err) { | ||||||
|  |             // LocalStorage and Cookies are probably disabled. Do not track the user.
 | ||||||
|  |             uuid = 'not-trackable-' + H5P.createUUID(); | ||||||
|  |         } | ||||||
|  |         this.data.statement.actor = { | ||||||
|  |             'account': { | ||||||
|  |                 'name': uuid, | ||||||
|  |                 'homePage': H5PIntegration.siteUrl | ||||||
|  |             }, | ||||||
|  |             'objectType': 'Agent' | ||||||
|  |         }; | ||||||
|  |     } | ||||||
|  | }; | ||||||
|  | |||||||
| @ -19,10 +19,8 @@ import { CoreSites } from '@services/sites'; | |||||||
| import { CoreMimetypeUtils } from '@services/utils/mimetype'; | import { CoreMimetypeUtils } from '@services/utils/mimetype'; | ||||||
| import { CoreTextUtils } from '@services/utils/text'; | import { CoreTextUtils } from '@services/utils/text'; | ||||||
| import { CoreUtils } from '@services/utils/utils'; | import { CoreUtils } from '@services/utils/utils'; | ||||||
| import { CoreUser } from '@features/user/services/user'; |  | ||||||
| import { CoreH5P } from '../services/h5p'; | import { CoreH5P } from '../services/h5p'; | ||||||
| import { CoreH5PCore, CoreH5PDisplayOptions } from './core'; | import { CoreH5PCore, CoreH5PDisplayOptions } from './core'; | ||||||
| import { Translate } from '@singletons'; |  | ||||||
| import { CoreError } from '@classes/errors/error'; | import { CoreError } from '@classes/errors/error'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -117,11 +115,11 @@ export class CoreH5PHelper { | |||||||
| 
 | 
 | ||||||
|         const site = await CoreSites.getSite(siteId); |         const site = await CoreSites.getSite(siteId); | ||||||
| 
 | 
 | ||||||
|         const userId = site.getUserId(); |         const info = site.getInfo(); | ||||||
|         const user = await CoreUtils.ignoreErrors(CoreUser.getProfile(userId, undefined, false, siteId)); |  | ||||||
| 
 | 
 | ||||||
|         if (!user || !user.email) { |         if (!info) { | ||||||
|             throw new CoreError(Translate.instant('core.h5p.errorgetemail')); |             // Shouldn't happen for authenticated sites.
 | ||||||
|  |             throw new CoreError('Site info could not be fetched.'); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const basePath = CoreFile.getBasePathInstant(); |         const basePath = CoreFile.getBasePathInstant(); | ||||||
| @ -151,7 +149,7 @@ export class CoreH5PHelper { | |||||||
|             l10n: { |             l10n: { | ||||||
|                 H5P: CoreH5P.h5pCore.getLocalization(), // eslint-disable-line @typescript-eslint/naming-convention
 |                 H5P: CoreH5P.h5pCore.getLocalization(), // eslint-disable-line @typescript-eslint/naming-convention
 | ||||||
|             }, |             }, | ||||||
|             user: { name: site.getInfo()!.fullname, mail: user.email }, |             user: { name: info.username, id: info.userid }, | ||||||
|             hubIsEnabled: false, |             hubIsEnabled: false, | ||||||
|             reportingIsEnabled: false, |             reportingIsEnabled: false, | ||||||
|             crossorigin: null, |             crossorigin: null, | ||||||
| @ -252,7 +250,8 @@ export type CoreH5PCoreSettings = { | |||||||
|     }; |     }; | ||||||
|     user: { |     user: { | ||||||
|         name: string; |         name: string; | ||||||
|         mail: string; |         id?: number; | ||||||
|  |         mail?: string; | ||||||
|     }; |     }; | ||||||
|     hubIsEnabled: boolean; |     hubIsEnabled: boolean; | ||||||
|     reportingIsEnabled: boolean; |     reportingIsEnabled: boolean; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user